public final class OidcTokenExchange
extends java.lang.Object
/oauth2/token endpoint
for exchanging authorisation codes and refreshing tokens.
All methods read configuration from OidcConfig and POST
form-encoded requests to the Cognito token endpoint.
| Modifier and Type | Method and Description |
|---|---|
static OidcTokenResponse |
exchangeAuthCode(java.lang.String code)
Exchanges an authorisation code for tokens using the
authorization_code grant type. |
static OidcTokenResponse |
parseTokenResponse(java.lang.String responseBody)
Parses a successful JSON response into an
OidcTokenResponse. |
static OidcTokenResponse |
postTokenRequest(java.lang.String tokenEndpoint,
java.lang.String formBody)
Posts a form-encoded request to the given token endpoint and parses
the JSON response.
|
static OidcTokenResponse |
refreshTokens(java.lang.String refreshToken)
Exchanges a refresh token for new access and ID tokens using the
refresh_token grant type. |
@CheckReturnValue @Nonnull public static OidcTokenResponse exchangeAuthCode(@Nonnull java.lang.String code) throws OidcTokenExchangeException
authorization_code grant type.code - the authorisation code received from Cognito's callbackOidcTokenExchangeException - if Cognito returns an error or the request fails@CheckReturnValue @Nonnull public static OidcTokenResponse refreshTokens(@Nonnull java.lang.String refreshToken) throws OidcTokenExchangeException
refresh_token grant type.
Note: Cognito does not return a new refresh token in the response for refresh_token grants.
refreshToken - the refresh tokenOidcTokenExchangeException - if Cognito returns an error or the request fails@CheckReturnValue @Nonnull public static OidcTokenResponse postTokenRequest(@Nonnull java.lang.String tokenEndpoint, @Nonnull java.lang.String formBody) throws OidcTokenExchangeException
tokenEndpoint - the Cognito token endpoint URLformBody - the URL-encoded form bodyOidcTokenExchangeException - on HTTP or parsing errors@CheckReturnValue @Nonnull public static OidcTokenResponse parseTokenResponse(@Nonnull java.lang.String responseBody) throws OidcTokenExchangeException
OidcTokenResponse.OidcTokenExchangeExceptionstSoftware Copyright © 2001-2014 stSoftware All Rights Reserved.