public class HttpCredentialsAdapter extends Object implements com.google.api.client.http.HttpRequestInitializer, com.google.api.client.http.HttpUnsuccessfulResponseHandler
Constructor and Description |
---|
HttpCredentialsAdapter(Credentials credentials) |
Modifier and Type | Method and Description |
---|---|
Credentials |
getCredentials()
A getter for the credentials instance being used
|
boolean |
handleResponse(com.google.api.client.http.HttpRequest request,
com.google.api.client.http.HttpResponse response,
boolean supportsRetry) |
void |
initialize(com.google.api.client.http.HttpRequest request) |
public HttpCredentialsAdapter(Credentials credentials)
credentials
- Credentials instance to adapt for HTTPpublic Credentials getCredentials()
public void initialize(com.google.api.client.http.HttpRequest request) throws IOException
Initialize the HTTP request prior to execution.
initialize
in interface com.google.api.client.http.HttpRequestInitializer
request
- HTTP requestIOException
public boolean handleResponse(com.google.api.client.http.HttpRequest request, com.google.api.client.http.HttpResponse response, boolean supportsRetry)
Checks if WWW-Authenticate
exists and contains a "Bearer" value (see rfc6750 section 3.1 for more
details). If so, it refreshes the token in case the error code contains invalid_token
.
If there is no "Bearer" in WWW-Authenticate
and the status code is HttpStatusCodes.STATUS_CODE_UNAUTHORIZED
it refreshes the token. If the token refresh throws
an I/O exception, this implementation will log the exception and return false
.
handleResponse
in interface com.google.api.client.http.HttpUnsuccessfulResponseHandler
Copyright © 2023 Google. All rights reserved.