com.google.api.client.googleapis.auth.oauth2
Class GoogleRefreshTokenRequest
java.lang.Object
java.util.AbstractMap<String,Object>
com.google.api.client.util.GenericData
com.google.api.client.auth.oauth2.TokenRequest
com.google.api.client.auth.oauth2.RefreshTokenRequest
com.google.api.client.googleapis.auth.oauth2.GoogleRefreshTokenRequest
- All Implemented Interfaces:
- Cloneable, Map<String,Object>
public class GoogleRefreshTokenRequest
- extends RefreshTokenRequest
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 JacksonFactory(),
"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.
- Since:
- 1.7
- Author:
- Yaniv Inbar
| Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
GoogleRefreshTokenRequest
public GoogleRefreshTokenRequest(HttpTransport transport,
JsonFactory jsonFactory,
String refreshToken,
String clientId,
String clientSecret)
- Parameters:
transport - HTTP transportjsonFactory - JSON factoryrefreshToken - refresh token issued to the clientclientId - client identifier issued to the client during the registration processclientSecret - client secret
setRequestInitializer
public GoogleRefreshTokenRequest setRequestInitializer(HttpRequestInitializer requestInitializer)
- Overrides:
setRequestInitializer in class RefreshTokenRequest
setTokenServerUrl
public GoogleRefreshTokenRequest setTokenServerUrl(GenericUrl tokenServerUrl)
- Overrides:
setTokenServerUrl in class RefreshTokenRequest
setScopes
public GoogleRefreshTokenRequest setScopes(String... scopes)
- Overrides:
setScopes in class RefreshTokenRequest
setScopes
public GoogleRefreshTokenRequest setScopes(Iterable<String> scopes)
- Overrides:
setScopes in class RefreshTokenRequest
setGrantType
public GoogleRefreshTokenRequest setGrantType(String grantType)
- Overrides:
setGrantType in class RefreshTokenRequest
setClientAuthentication
public GoogleRefreshTokenRequest setClientAuthentication(HttpExecuteInterceptor clientAuthentication)
- Overrides:
setClientAuthentication in class RefreshTokenRequest
setRefreshToken
public GoogleRefreshTokenRequest setRefreshToken(String refreshToken)
- Overrides:
setRefreshToken in class RefreshTokenRequest
execute
public GoogleTokenResponse execute()
throws IOException
- Overrides:
execute in class TokenRequest
- Throws:
IOException
Copyright © 2010-2012 Google. All Rights Reserved.