This implementation assumes that the {@link HttpRequest#getContent()} is {@code null} or aninstance of {@link UrlEncodedContent}. This is used as the client authentication in {@link TokenRequest#setClientAuthentication(HttpExecuteInterceptor)}.
Sample usage:
static void requestAccessToken() throws IOException { try { TokenResponse response = new AuthorizationCodeTokenRequest(new NetHttpTransport(), new JacksonFactory(), new GenericUrl("https://server.example.com/token"), "SplxlOBeZQQYbYS6WxSbIA").setRedirectUri("https://client.example.com/rd") .setClientAuthentication( new ClientParametersAuthentication("s6BhdRkqt3", "7Fjfp0ZBr1KtDRbnfVdmIw")).execute(); System.out.println("Access token: " + response.getAccessToken()); } catch (TokenResponseException e) { if (e.getDetails() != null) { System.err.println("Error: " + e.getDetails().getError()); if (e.getDetails().getErrorDescription() != null) { System.err.println(e.getDetails().getErrorDescription()); } if (e.getDetails().getErrorUri() != null) { System.err.println(e.getDetails().getErrorUri()); } } else { System.err.println(e.getMessage()); } } }
Implementation is immutable and thread-safe.
@since 1.7 @author Yaniv Inbar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|