useExternalAuth hook provides verifyWithExternalJwt to exchange your backend’s assertion JWT for an elevated access token.
This is useful when your backend has already verified the user’s identity through its own means (e.g., a session, an internal auth check, or a custom challenge) and you want to authorize a sensitive Dynamic operation without additional user friction.
For concepts, scopes, and token lifecycle, see Step-up authentication overview.
Prerequisites
DynamicContextProviderconfigured with your environment ID- External auth (BYOA) configured with a JWKS URL in your dashboard
- The user is already signed in via external auth
How it works
- Your backend creates an assertion JWT signed with the same key registered in your environment’s JWKS URL.
- The
verifyWithExternalJwtmethod sends this JWT to Dynamic’s backend, which validates the signature and issues an elevated access token. - The elevated token is automatically stored in SDK state and attached to subsequent API calls — no manual token handling is needed.
Assertion JWT requirements
Your backend must sign a JWT with the following claims:| Claim | Required | Description |
|---|---|---|
sub | Yes | The user’s external user ID (must match the signed-in user) |
scope | Yes | Space-delimited scopes to request (e.g., "wallet:export") |
jti | Yes | A unique token identifier (prevents replay attacks) |
exp | Yes | Expiration time (Unix timestamp in seconds) |
Quick start
Combining with isStepUpRequired
Use isStepUpRequired to check whether step-up is needed before calling your backend:
Full example: credential unlinking with error handling
When to use external auth vs. other methods
| Approach | Best for |
|---|---|
External auth (verifyWithExternalJwt) | BYOA setups where your backend controls identity verification. No user interaction needed on the client. |
promptStepUpAuth | When you want Dynamic to handle user verification with its built-in UI. |
| Individual verify methods | Headless custom UI where Dynamic handles the verification logic. |
useExternalAuth reference
| Method | Description |
|---|---|
signInWithExternalJwt({ externalUserId, externalJwt? }) | Signs in a user with an external JWT. Returns UserProfile. |
verifyWithExternalJwt({ externalJwt }) | Exchanges an assertion JWT for an elevated access token. The token is automatically stored and applied. |
Related
- Step-Up Authentication Overview — Concepts, scopes, token lifecycle
- Bring Your Own Auth — Configuring external auth
- React SDK Step-Up Guide — Re-auth, MFA, and Dynamic’s built-in UI