Google-specific implementation of the OAuth 2.0 request to refresh an access token using a
refresh token as specified in Refreshing
an Access Token.
Use GoogleCredential to access protected resources from the resource server using the
TokenResponse returned by #execute(). On error, it will instead throw TokenResponseException.
Sample usage:
static void refreshAccessToken() throws IOException {
try {
TokenResponse response = new GoogleRefreshTokenRequest(
new NetHttpTransport(), new GsonFactory(),
"tGzv3JOkF0XG5Qx2TlKWIA", "s6BhdRkqt3",
"7Fjfp0ZBr1KtDRbnfVdmIw").execute();
System.out.println("Access token: " + response.getAccessToken());
} catch (TokenResponseException e) {
if (e.getDetails() != null) {
System.err.println("Error: " + e.getDetails().getError());
if (e.getDetails().getErrorDescription() != null) {
System.err.println(e.getDetails().getErrorDescription());
}
if (e.getDetails().getErrorUri() != null) {
System.err.println(e.getDetails().getErrorUri());
}
} else {
System.err.println(e.getMessage());
}
}
}
Implementation is not thread-safe.
Inherited Members
com.google.api.client.auth.oauth2.RefreshTokenRequest.getRefreshToken()
com.google.api.client.auth.oauth2.RefreshTokenRequest.set(java.lang.String,java.lang.Object)
com.google.api.client.auth.oauth2.RefreshTokenRequest.setClientAuthentication(com.google.api.client.http.HttpExecuteInterceptor)
com.google.api.client.auth.oauth2.RefreshTokenRequest.setGrantType(java.lang.String)
com.google.api.client.auth.oauth2.RefreshTokenRequest.setRefreshToken(java.lang.String)
com.google.api.client.auth.oauth2.RefreshTokenRequest.setRequestInitializer(com.google.api.client.http.HttpRequestInitializer)
com.google.api.client.auth.oauth2.RefreshTokenRequest.setResponseClass(java.lang.Class<? extends com.google.api.client.auth.oauth2.TokenResponse>)
com.google.api.client.auth.oauth2.RefreshTokenRequest.setScopes(java.util.Collection<java.lang.String>)
com.google.api.client.auth.oauth2.RefreshTokenRequest.setTokenServerUrl(com.google.api.client.http.GenericUrl)
com.google.api.client.auth.oauth2.TokenRequest.execute()
com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed()
com.google.api.client.auth.oauth2.TokenRequest.getClientAuthentication()
com.google.api.client.auth.oauth2.TokenRequest.getGrantType()
com.google.api.client.auth.oauth2.TokenRequest.getJsonFactory()
com.google.api.client.auth.oauth2.TokenRequest.getRequestInitializer()
com.google.api.client.auth.oauth2.TokenRequest.getResponseClass()
com.google.api.client.auth.oauth2.TokenRequest.getScopes()
com.google.api.client.auth.oauth2.TokenRequest.getTokenServerUrl()
com.google.api.client.auth.oauth2.TokenRequest.getTransport()
com.google.api.client.util.GenericData.clone()
com.google.api.client.util.GenericData.entrySet()
com.google.api.client.util.GenericData.equals(java.lang.Object)
com.google.api.client.util.GenericData.get(java.lang.Object)
com.google.api.client.util.GenericData.getClassInfo()
com.google.api.client.util.GenericData.getUnknownKeys()
com.google.api.client.util.GenericData.hashCode()
com.google.api.client.util.GenericData.put(java.lang.String,java.lang.Object)
com.google.api.client.util.GenericData.putAll(java.util.Map<? extends java.lang.String,?>)
com.google.api.client.util.GenericData.remove(java.lang.Object)
com.google.api.client.util.GenericData.setUnknownKeys(java.util.Map<java.lang.String,java.lang.Object>)
com.google.api.client.util.GenericData.toString()