public class GoogleRefreshTokenRequest extends 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.
GenericData.FlagsAbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>responseClass| Constructor and Description |
|---|
GoogleRefreshTokenRequest(HttpTransport transport,
JsonFactory jsonFactory,
String refreshToken,
String clientId,
String clientSecret) |
| Modifier and Type | Method and Description |
|---|---|
GoogleTokenResponse |
execute() |
GoogleRefreshTokenRequest |
set(String fieldName,
Object value) |
GoogleRefreshTokenRequest |
setClientAuthentication(HttpExecuteInterceptor clientAuthentication) |
GoogleRefreshTokenRequest |
setGrantType(String grantType) |
GoogleRefreshTokenRequest |
setRefreshToken(String refreshToken) |
GoogleRefreshTokenRequest |
setRequestInitializer(HttpRequestInitializer requestInitializer) |
GoogleRefreshTokenRequest |
setScopes(Collection<String> scopes) |
GoogleRefreshTokenRequest |
setTokenServerUrl(GenericUrl tokenServerUrl) |
getRefreshToken, setResponseClassexecuteUnparsed, getClientAuthentication, getGrantType, getJsonFactory, getRequestInitializer, getResponseClass, getScopes, getTokenServerUrl, getTransportclone, entrySet, equals, get, getClassInfo, getUnknownKeys, hashCode, put, putAll, remove, setUnknownKeys, toStringclear, containsKey, containsValue, isEmpty, keySet, size, valuesfinalize, getClass, notify, notifyAll, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllpublic GoogleRefreshTokenRequest(HttpTransport transport, JsonFactory jsonFactory, String refreshToken, String clientId, 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(HttpRequestInitializer requestInitializer)
setRequestInitializer in class RefreshTokenRequestpublic GoogleRefreshTokenRequest setTokenServerUrl(GenericUrl tokenServerUrl)
setTokenServerUrl in class RefreshTokenRequestpublic GoogleRefreshTokenRequest setScopes(Collection<String> scopes)
setScopes in class RefreshTokenRequestpublic GoogleRefreshTokenRequest setGrantType(String grantType)
setGrantType in class RefreshTokenRequestpublic GoogleRefreshTokenRequest setClientAuthentication(HttpExecuteInterceptor clientAuthentication)
setClientAuthentication in class RefreshTokenRequestpublic GoogleRefreshTokenRequest setRefreshToken(String refreshToken)
setRefreshToken in class RefreshTokenRequestpublic GoogleTokenResponse execute() throws IOException
execute in class TokenRequestIOExceptionpublic GoogleRefreshTokenRequest set(String fieldName, Object value)
set in class RefreshTokenRequestCopyright © 2010–2020 Google. All rights reserved.