Skip to content

Conversation

@yogeshchoudhary147
Copy link
Contributor

Description

Adds support for the organization parameter in the token exchange flow (exchangeToken method) to enable organization-specific authentication.

Changes

  • Added organization as an optional parameter to CustomTokenExchangeOptions interface
  • Updated exchangeToken method to conditionally pass organization to the /oauth/token endpoint
  • Updated JSDoc documentation with organization parameter details and usage example
  • Added test coverage for organization parameter (both provided and not provided scenarios)

API Changes

The /oauth/token endpoint now accepts an optional organization parameter for the token exchange grant type. When provided, the organization ID will be present in the access token payload.

Testing

  • ✅ Added test: passes organization parameter to _requestToken when provided
  • ✅ Added test: does not pass organization parameter when not provided
  • ✅ All existing tests pass

Example Usage

const tokenResponse = await auth0Client.exchangeToken({
  subject_token: 'external_token',
  subject_token_type: 'urn:acme:legacy-system-token',
  scope: 'openid profile',
  organization: 'org_12345'
});
// Organization ID will be in access token payload

- Add optional organization parameter to CustomTokenExchangeOptions
- Pass organization to /oauth/token endpoint in exchangeToken method
- Update JSDoc with organization parameter documentation and examples
- Add test cases for organization parameter (provided and not provided)

When organization is provided, the organization ID will be present in the access token payload, enabling organization-specific authentication context.
@yogeshchoudhary147 yogeshchoudhary147 requested a review from a team as a code owner December 4, 2025 17:19
@yogeshchoudhary147 yogeshchoudhary147 merged commit 8656744 into main Dec 8, 2025
14 checks passed
@yogeshchoudhary147 yogeshchoudhary147 deleted the feat/add-organization-support-token-exchange branch December 8, 2025 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants