.setTokenServerEncodedUrl(tokenServerUrl)
.build();
credential.setRefreshToken(refreshToken);
try {
if (!oAuth2Helper.callRefreshToken(credential)) {
throw new OAuthException(
"Credential could not be refreshed. A newly generated refresh token may be required.");
}
} catch (IOException e) {
throw new OAuthException("Credential could not be refreshed.", e);
}
return credential;
}