10Duke Java Core
|
Implementation of an OAuth device flow client.
Note: the second phase construction method init()
must be used prior to running an OAuth flow.
Public Member Functions | |
DeviceFlowClient (final AuthConfig config, final OkHttpProvider okHttpProvider, final JwtServiceProvider jwtServiceProvider, final ObjectMapper mapper) | |
Class constructor. | |
DeviceAuthResponse | authorize () throws IOException |
Starts the device flow by running the device code request. | |
VerifiedOAuthTokenResponse | requestToken (final String deviceCode) throws IOException |
Makes the access token request to the authorization server. | |
![]() | |
AbstractOAuthClient (final AuthConfig config, final OkHttpProvider okHttpProvider, final JwtServiceProvider jwtServiceProvider, final ObjectMapper mapper) | |
Class constructor. | |
void | init () |
Second phase construction hook provided for controlling potentially slow loading of remote OpenId configuration. | |
VerifiedOAuthTokenResponse | refreshToken (final String refreshToken) throws IOException |
Makes an access token refresh request to the authorization server. | |
boolean | checkIfJwksUriIsConfigured () |
Checks if this client instance has configuration for the JWKS endpoint. | |
boolean | reloadJwks () |
Requests this client instance to reload keys from the JWKS endpoint. | |
Protected Member Functions | |
void | assertStateIsValid () |
Analyzes state and configuration. | |
boolean | supportsTokenRefresh () |
Returns flag that tells if the OAuth client implementation supports token refresh. | |
![]() | |
VerifiedOAuthTokenResponse | parseTokenResponse (final Response response) |
Parses a token response received from the authorization server (Identity Provider). | |
void | loadOpenIdConnectConfiguration () |
Loads OpenId configuration from configured URL (only if discovery URL is available in configuration). | |
String | formatConfigMissingMessage (final String formatValue) |
Formats a message for a missing configuration value. | |
String | formatRuntimeDependencyMissingMessage (final String formatValue) |
Formats a message for a missing configuration value. | |
boolean | updateSigningKeys (final OpenIdConfiguration effectiveOidcConfig, final JwtServiceProvider jwtSp) |
Updates signing keys based on OpenIdConfiguration that has been loaded or changed. | |
tenduke.sdk.core.auth.DeviceFlowClient.DeviceFlowClient | ( | final AuthConfig | config, |
final OkHttpProvider | okHttpProvider, | ||
final JwtServiceProvider | jwtServiceProvider, | ||
final ObjectMapper | mapper ) |
Class constructor.
config | The configuration to use for OAuth client_id and endpoints at the authorization provider, |
okHttpProvider | Provides OkHttpClient instance(s). |
jwtServiceProvider | Provides JwtService instances. |
mapper | Jackson object mapper, needed for parsing access token response JSON. |
|
protected |
Analyzes state and configuration.
Throws IllegalStateException
if:
Required values are checked to ensure they are not null and conform to expected grammar (for example URIs are formatted correctly).
Reimplemented from tenduke.sdk.core.auth.AbstractOAuthClient.
DeviceAuthResponse tenduke.sdk.core.auth.DeviceFlowClient.authorize | ( | ) | throws IOException |
Starts the device flow by running the device code request.
IOException | For an IO exception while making the HTTP request. |
VerifiedOAuthTokenResponse tenduke.sdk.core.auth.DeviceFlowClient.requestToken | ( | final String | deviceCode | ) | throws IOException |
Makes the access token request to the authorization server.
Call this method when:
and try the token request after waiting a while.
The use of an exponential backoff algorithm to achieve this, such as doubling the polling interval on each such connection timeout, is RECOMMENDED. Before each new request, the client MUST wait at least the number of seconds specified by the "interval" parameter of the device authorization response.
deviceCode | The device authorization code that verifies the token request is legit and is paired with the authorization the user provided. |
OAuthTokenResponse#checkIsSuccess()
and OAuthTokenResponse#checkIsError()
methods of OAuthTokenResponse
to determine if getting the id token or error code is the next step.IOException | for IO errors while making the HTTP request. |
|
protected |
Returns flag that tells if the OAuth client implementation supports token refresh.
Reimplemented from tenduke.sdk.core.auth.AbstractOAuthClient.