String code = requireParameter(req, "code");
log.info("code=" + code);
log.info("clientId=" + clientId + ", clientSecret=" + clientSecret + ", code=" + code
+ ", callbackUrl=" + callbackUrl);
GoogleAuthorizationCodeGrant authRequest = new GoogleAuthorizationCodeGrant(
new UrlFetchTransport(), new JacksonFactory(), clientId, clientSecret, code, callbackUrl);
AccessTokenResponse authResponse;
try {
authResponse = authRequest.execute();
} catch (IOException e) {
log.log(Level.WARNING, "Failed attempt, trying again", e);
if (e instanceof HttpResponseException) {
HttpResponseException f = (HttpResponseException) e;
ByteArrayOutputStream o = new ByteArrayOutputStream();