public class GoogleRefreshTokenRequest
extends com.google.api.client.auth.oauth2.RefreshTokenRequest
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.
com.google.api.client.util.GenericData.Flags| Constructor and Description |
|---|
GoogleRefreshTokenRequest(com.google.api.client.http.HttpTransport transport,
com.google.api.client.json.JsonFactory jsonFactory,
java.lang.String refreshToken,
java.lang.String clientId,
java.lang.String clientSecret) |
| Modifier and Type | Method and Description |
|---|---|
GoogleTokenResponse |
execute() |
GoogleRefreshTokenRequest |
set(java.lang.String fieldName,
java.lang.Object value) |
GoogleRefreshTokenRequest |
setClientAuthentication(com.google.api.client.http.HttpExecuteInterceptor clientAuthentication) |
GoogleRefreshTokenRequest |
setGrantType(java.lang.String grantType) |
GoogleRefreshTokenRequest |
setRefreshToken(java.lang.String refreshToken) |
GoogleRefreshTokenRequest |
setRequestInitializer(com.google.api.client.http.HttpRequestInitializer requestInitializer) |
GoogleRefreshTokenRequest |
setScopes(java.util.Collection<java.lang.String> scopes) |
GoogleRefreshTokenRequest |
setTokenServerUrl(com.google.api.client.http.GenericUrl tokenServerUrl) |
executeUnparsed, getClientAuthentication, getGrantType, getJsonFactory, getRequestInitializer, getScopes, getTokenServerUrl, getTransportclone, entrySet, get, getClassInfo, getUnknownKeys, put, putAll, remove, setUnknownKeysclear, containsKey, containsValue, equals, hashCode, isEmpty, keySet, size, toString, valuespublic GoogleRefreshTokenRequest(com.google.api.client.http.HttpTransport transport,
com.google.api.client.json.JsonFactory jsonFactory,
java.lang.String refreshToken,
java.lang.String clientId,
java.lang.String clientSecret)
transport - HTTP transportjsonFactory - JSON factoryrefreshToken - refresh token issued to the clientclientId - client identifier issued to the client during the registration processclientSecret - client secretpublic GoogleRefreshTokenRequest setRequestInitializer(com.google.api.client.http.HttpRequestInitializer requestInitializer)
setRequestInitializer in class com.google.api.client.auth.oauth2.RefreshTokenRequestpublic GoogleRefreshTokenRequest setTokenServerUrl(com.google.api.client.http.GenericUrl tokenServerUrl)
setTokenServerUrl in class com.google.api.client.auth.oauth2.RefreshTokenRequestpublic GoogleRefreshTokenRequest setScopes(java.util.Collection<java.lang.String> scopes)
setScopes in class com.google.api.client.auth.oauth2.RefreshTokenRequestpublic GoogleRefreshTokenRequest setGrantType(java.lang.String grantType)
setGrantType in class com.google.api.client.auth.oauth2.RefreshTokenRequestpublic GoogleRefreshTokenRequest setClientAuthentication(com.google.api.client.http.HttpExecuteInterceptor clientAuthentication)
setClientAuthentication in class com.google.api.client.auth.oauth2.RefreshTokenRequestpublic GoogleRefreshTokenRequest setRefreshToken(java.lang.String refreshToken)
setRefreshToken in class com.google.api.client.auth.oauth2.RefreshTokenRequestpublic GoogleTokenResponse execute() throws java.io.IOException
execute in class com.google.api.client.auth.oauth2.TokenRequestjava.io.IOExceptionpublic GoogleRefreshTokenRequest set(java.lang.String fieldName, java.lang.Object value)
set in class com.google.api.client.auth.oauth2.RefreshTokenRequestCopyright © 2010-2019 Google. All Rights Reserved.