public interface Authenticator
When authentication is requested by an origin server, the response code is 401 and the implementation should respond with a new request that sets the "Authorization" header.
String credential = Credentials.basic(...)
return response.request().newBuilder()
.header("Authorization", credential)
.build();
When authentication is requested by a proxy server, the response code is 407 and the implementation should respond with a new request that sets the "Proxy-Authorization" header.
String credential = Credentials.basic(...)
return response.request().newBuilder()
.header("Proxy-Authorization", credential)
.build();
Applications may configure OkHttp with an authenticator for origin servers, or proxy servers, or both.
| Modifier and Type | Field and Description |
|---|---|
static Authenticator |
NONE
An authenticator that knows no credentials and makes no attempt to authenticate.
|
| Modifier and Type | Method and Description |
|---|---|
Request |
authenticate(Route route,
Response response)
Returns a request that includes a credential to satisfy an authentication challenge in
response. |
static final Authenticator NONE
Request authenticate(Route route, Response response) throws IOException
response. Returns null if the challenge cannot be satisfied.IOExceptionCopyright © 2016. All Rights Reserved.