feat: Custom Token Exchange support#141
Merged
Merged
Conversation
rmad17
marked this pull request as ready for review
July 12, 2026 09:56
kishore7snehil
requested changes
Jul 13, 2026
| await auth_client.handle_backchannel_logout(invalid_token) | ||
|
|
||
|
|
||
| class TestCustomTokenExchange: |
Contributor
There was a problem hiding this comment.
These tests should go at the last. We should avoid adding new tests in middle of file until it's relevant to the existing class or function.
kishore7snehil
requested changes
Jul 13, 2026
| ) | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_login_with_custom_token_exchange_passes_store_options_for_session_write( |
Contributor
There was a problem hiding this comment.
These login-variant tests cover the happy path and store_options forwarding, but not two things the docs lean on: forwarding actor_token/actor_token_type through this method (the custom_token_exchange test above checks that, the login one doesn't), and the missing-response case that the README and examples call out as raising a ValueError.
Could we add a couple of small delegation tests here to lock both down?
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
Features
AuthClient):custom_token_exchangeandlogin_with_custom_token_exchange. Callcustom_token_exchangeto exchange a token for Auth0 tokens without touching the caller's session(service-to-service delegation, downstream API calls with a different audience/scope). Call
login_with_custom_token_exchangeto exchange a token and establish a full Auth0 session, same as completing/auth/callback.actor_token/actor_token_typeto represent a party acting on behalf of the subject; Auth0 surfaces this as theactclaim on the response(
custom_token_exchange) or persisted on the session user (login_with_custom_token_exchange).organizationparameter to scope the exchange to a specific org.CustomTokenExchangeErroris raised on exchange failure or invalid subject/actor token parameters, and is mapped to an HTTP400JSON response automatically onceAPI Changes
AuthClient.custom_token_exchange,AuthClient.login_with_custom_token_exchange.auth0_fastapi.errors:CustomTokenExchangeError,CustomTokenExchangeErrorCode(re-exported fromauth0-server-python).