tokenUrl = new URL(_baseOAuthUrl, "token");
} catch (MalformedURLException ex) {
throw new AssertionError(ex);
}
OAuthTokensRequest request = new OAuthTokensRequest();
request.setClientId(clientId);
request.setClientSecret(clientSecret);
request.setGrantType(OAuthTokensRequest.GrantType.AUTHORIZATION_CODE);
request.setCode(authCode);
request.setRedirectUri(redirectUri != null? redirectUri : "2_legged");
return post(tokenUrl, request, OAuthTokensResponse.class);
}