Skip to content

Conversation

@gyaneshgouraw-okta
Copy link
Contributor

@gyaneshgouraw-okta gyaneshgouraw-okta commented Nov 7, 2025

📝 Summary

This PR adds support for the exchangeToken method from auth0-spa-js to auth0-react, enabling token exchange flows based on RFC 8693 This allows apps to exchange external or legacy tokens for Auth0 tokens directly in React.

🔧 Changes

  • Added exchangeToken to the Auth0ContextInterface with full TypeScript and JSDoc support.
  • Implemented exchangeToken using a useCallback with proper error handling.
  • Updated the auth state after successful exchanges.
  • Updated useAuth0 docs to include the new method.
  • Added examples and best practices to EXAMPLES.md.

🧪 Testing

  • Added 4 new tests for method behavior, error handling, auth state updates, and memoization.
  • Updated Jest mocks for exchangeToken, with all tests passing and full TypeScript coverage.

💥 Impact

  • Enables secure token exchange following RFC 8693.
  • Helps migration from legacy auth systems.
  • Fully documented, type-safe, and consistent with existing SDK patterns.

@yogeshchoudhary147 yogeshchoudhary147 force-pushed the feat/custom-token-exchange branch from 3aa2710 to 56fc5c6 Compare November 19, 2025 08:29
@yogeshchoudhary147 yogeshchoudhary147 force-pushed the feat/custom-token-exchange branch from 56fc5c6 to c34a6bf Compare November 21, 2025 05:03
@yogeshchoudhary147 yogeshchoudhary147 marked this pull request as ready for review November 21, 2025 10:51
@yogeshchoudhary147 yogeshchoudhary147 requested a review from a team as a code owner November 21, 2025 10:51
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