try {
credentials = oAuthProviderHelp.exchangeCodeForToken(split[0], code);
} catch (IOException e) {
log.log(Level.WARNING, "Failed attempt, trying again", e);
if (e instanceof HttpResponseException) {
HttpResponseException f = (HttpResponseException) e;
ByteArrayOutputStream o = new ByteArrayOutputStream();
f.getResponse().getRequest().getContent().writeTo(o);
// TODO(ohler): Use correct character set.
log.warning("content of rejected request: " + o.toString());
log.warning("rejection response body: " + f.getResponse().parseAsString());
}
resp.sendRedirect(req.getRequestURI() + "?code=" + urlEncode(code) + "&state="
+ urlEncode(state) + "&tryagain=true");
return;
}