}
}
@Override
public void refreshToken(GoogleAccessTokenContext accessTokenContext) {
GoogleTokenResponse tokenData = accessTokenContext.getTokenData();
if (tokenData.getRefreshToken() == null) {
throw new OAuthException(OAuthExceptionCode.GOOGLE_ERROR, "Given GoogleTokenResponse does not contain refreshToken");
}
try {
GoogleRefreshTokenRequest refreshTokenRequest = new GoogleRefreshTokenRequest(TRANSPORT, JSON_FACTORY, tokenData.getRefreshToken(),
this.clientID, this.clientSecret);
GoogleTokenResponse refreshed = refreshTokenRequest.execute();
// Update only 'accessToken' with new value
tokenData.setAccessToken(refreshed.getAccessToken());
if (log.isTraceEnabled()) {
log.trace("AccessToken refreshed successfully with value " + refreshed.getAccessToken());
}
} catch (IOException ioe) {
throw new OAuthException(OAuthExceptionCode.GOOGLE_ERROR, ioe);
}
}