You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## 📝 Summary
This PR adds support for the `exchangeToken` method from
**auth0-spa-js** to **auth0-react**, enabling token exchange flows based
on [RFC 8693](https://www.rfc-editor.org/rfc/rfc8693.html) 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](https://www.rfc-editor.org/rfc/rfc8693.html).
* Helps migration from legacy auth systems.
* Fully documented, type-safe, and consistent with existing SDK
patterns.
---------
Co-authored-by: Yogesh Chaudhary <[email protected]>
- The `subject_token_type` must be a namespaced URI under your organization's control
152
+
- The external token must be validated in Auth0 Actions using strong cryptographic verification
153
+
- This method implements RFC 8693 token exchange grant type
154
+
- The audience and scope can be provided directly in the options or will fall back to SDK defaults
155
+
-**State Management:** This method triggers the `GET_ACCESS_TOKEN_COMPLETE` action internally upon completion. This ensures that the SDK's `isLoading` and `isAuthenticated` states behave identically to the standard `getAccessTokenSilently` flow.
156
+
102
157
## Protecting a route in a `react-router-dom v6` app
103
158
104
159
We need to access the `useNavigate` hook so we can use `navigate` in `onRedirectCallback` to return us to our `returnUrl`.
0 commit comments