OAuth2ProtocolClient
Implements the client side of OAuth 2.0, without sending any HTTP request itself: every call returns an HttpExchange, whose requests the caller sends with any HTTP stack. The KDoc of each method lists the ProtocolRequests its exchange sends; brackets mark optional requests, and {1,3} means the first attempt plus up to two retries.
Supported features:
Token requests and responses
DPoP nonces and attestation challenges are tracked per origin in this instance, and shared by all its exchanges. DPoP nonces from the authorization server and from resource servers are kept apart, even when both share an origin.
Constructors
Types
Used in ClientAttestation.loadInstanceAttestation to provide information about the authorization server.
Properties
Authenticates the client with an instance attestation, when the authorization server supports attestation-based client authentication; null for no client attestation.
Implements OAuth2 protocol, redirectUrl needs to be registered by the OS for this application, so redirection back from browser works
Functions
Headers to access resourceUrl with the access token from tokenResponse, i.e. HttpHeaders.Authorization and, for DPoP-bound tokens, HttpHeaders.DPoP. Uses dpopNonce, or the latest DPoP nonce that the resource server at that origin provided.
Calls the token introspection endpoint (OAuth2AuthorizationServerMetadata.introspectionEndpoint) to check whether the given token is active, finishes with the response on success, otherwise fails with InvalidToken. With verifyTokenIntrospectionJwt, it asks for a JWT response (RFC 9701 4.), and accepts it only with typ token-introspection+jwt, a verified signature, the authorization server as iss, and the client_id of oAuth2Client in aud (RFC 9701 5.).
Loads OAuth2AuthorizationServerMetadata from authorizationServer.
Uses the auth code to request an access token.
Uses a pre-authorized code from the authorization server to request an access token.
Uses the refresh token to request a new access token.
Uses an access token from another client to request a new access token, see RFC8693 OAuth 2.0 Token Exchange.
Builds the authorization request (AuthenticationRequestParameters) to start authentication at the authorization server.
Loads the user info from userInfoEndpoint with the access token from tokenResponse.