feat: add access token exchange and generic subject token type to Tok…#904
Draft
kailash-b wants to merge 2 commits into
Draft
feat: add access token exchange and generic subject token type to Tok…#904kailash-b wants to merge 2 commits into
kailash-b wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
This PR extends the Token Vault token-exchange support in
AuthAPIso callers can exchange access tokens (not just refresh tokens) for a federated identity provider's access token, and can specify an arbitrary subject token type when needed.Method changes on
com.auth0.client.auth.AuthAPI:getTokenForConnection(String connection, String subjectToken, String subjectTokenType, String loginHint)is now the generic entry point. The caller supplies both thesubjectTokenand itssubjectTokenType(e.g.urn:ietf:params:oauth:token-type:refresh_tokenorurn:ietf:params:oauth:token-type:access_token), so no assumption is made about which kind of token is being exchanged.getTokenForConnectionWithRefreshToken(String connection, String refreshToken, String loginHint)— convenience method that delegates to the generic method with the refresh-token subject type.getTokenForConnectionWithAccessToken(String connection, String accessToken, String loginHint)— convenience method that delegates with the access-token subject type.getTokenForConnection(String connection, String refreshToken, String loginHint)3-argument overload. It now delegates togetTokenForConnectionWithRefreshToken(...)for backward compatibility. Callers should migrate to the new convenience methods, or to the 4-argument generic method for full control.All methods use the Token Vault grant
urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token. The connection must have Token Vault enabled, and client authentication (client secret or client assertion) is required since this must be a private client.Usage:
References
Testing
Unit tests were added in
AuthAPITestcovering the new access-token and generic token-type exchange paths, the new convenience methods, the deprecated overload's delegation, and null-argument assertions.Checklist