.ietf.org/html/draft-ietf-oauth-v2-23#section-6">Refreshing an Access Token.
Use {@link GoogleCredential} to access protected resources from the resource server using the{@link TokenResponse} returned by {@link #execute()}. On error, it will instead throw {@link 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