feat(auth0-express-api): add support for on-behalf-of token exchange - #40
Merged
Merged
Conversation
nandan-bhat
force-pushed
the
feat/sdk-8431-api-as-client-obo
branch
2 times, most recently
from
August 19, 2026 23:21
34daf6e to
033b19f
Compare
nandan-bhat
force-pushed
the
feat/sdk-8431-api-as-client-obo
branch
from
August 19, 2026 23:47
033b19f to
a4711ed
Compare
kishore7snehil
requested changes
Aug 20, 2026
Piyush-85
reviewed
Aug 20, 2026
Piyush-85
approved these changes
Aug 20, 2026
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.
What changed
chore: bump auth0-api-js and re-export its public API@auth0/auth0-api-jsgoes from^1.4.0to^1.6.1, since OBOTE (On-behalf-Of Token Exchange) landed in1.6.0. Re-exports only what this package's surface already exposes: the actor claim helpers, the errors it can throw, the OBO types, andApiClientas a type only, socreateAuth0Api()stays the only way to build a client.feat: on-behalf-of token exchangerequiresAuth()now setsreq.auth0.tokenalongsidereq.auth0.user, so a token on the request is always one this API has verified. It is non-enumerable, soJSON.stringify, spreads andconsole.logleave it out.req.auth0.client.getTokenOnBehalfOf(token, { audience, scope })and pass the subject token yourself.req.auth0.token. Anywhere else it can be a token your API holds for elsewhere, such as one stored for a background job.clientIdplus eitherclientSecretorclientAssertionSigningKey.EXAMPLES.mdgains an API as a client section, which is where token verification and token exchange get separated. It covers the tenant prerequisites, the two errors, and why a subject token must never come from the request.Usage Example
Testing
msw, a missing subject token, missingcredentials and a tenant rejection
npm run buildandnpm run lintare clean