Overview
Custom authentication enables applications with existing authentication systems to integrate Embedded Wallets seamlessly. Instead of using CDP’s built-in authentication methods (email OTP, SMS, OAuth), you can use JSON Web Tokens (JWTs) from your own Identity Provider. This approach is ideal when:- You already have users authenticated via Auth0, Firebase, AWS Cognito, or a custom solution
- You want to implement single sign-on (SSO) across your entire platform
- You need to integrate with corporate identity systems
- You must use specific authentication providers for regulatory compliance
How it works
Custom authentication follows a straightforward flow that leverages your existing identity infrastructure:Pre-authentication setup
Pre-authentication setup
Before users can authenticate, you configure your JWKS (JSON Web Key Set) endpoint in the CDP Portal. This allows CDP to verify the authenticity of JWTs issued by your Identity Provider.
Authentication flow
Authentication flow
- User logs in: The user authenticates with your existing authentication system (Auth0, Firebase, etc.)
- JWT generation: Your Identity Provider generates a valid JWT for the authenticated user
- CDP integration: Your application provides the JWT to CDP via the
customAuth.getJwtcallback - JWT validation: CDP retrieves your JWKS endpoint (configured in Portal), validates the JWT signature, and checks required claims (
iss,sub,exp,iat) - Wallet access: Upon successful validation, CDP uses the stable, verified
subclaim (user ID) to get or create an embedded wallet for the user
Session management
Session management
Unlike CDP’s built-in authentication, custom auth sessions are managed entirely by your Identity Provider:
- CDP always requests a fresh JWT via the
getJwtcallback when needed - Token refresh is handled by your IDP, not CDP
- Session duration is controlled by your IDP’s configuration
- Users must sign out from both your IDP and CDP
Prerequisites
Before implementing custom authentication, ensure you have:CDP Portal configuration
- A CDP project with a Project ID
- Your JWKS endpoint configured in the CDP Portal (see Portal Configuration below)
Identity Provider requirements
Your Identity Provider must support:- JWKS (JSON Web Key Sets) with RS256 or ES256 signing algorithms
- Required JWT claims:
iss(issuer): Your Identity Provider’s domainsub(subject): Unique identifier that identifies the particular user on your applicationexp(expiration): Token expiration timestampiat(issued at): Token issuance timestamp
Portal Configuration
To configure custom authentication in the CDP Portal:- Navigate to your project in the CDP Portal
- Locate your custom authentication settings under your project configuration

- Enable custom authentication by switching on the toggle if you had not yet
- Add your JWKS endpoint URL
- For example, it may look like
https://YOUR_DOMAIN.auth0.com/.well-known/jwks.jsonif you are using Auth0 as your IDP
- For example, it may look like
- Configure expected claims:
- Issuer (
iss): Your Identity Provider’s domain. Note that you are required to specify the issuer. - Audience (
aud): Your API or app identifier
- Issuer (
- Save your configuration
SDK Integration
The CDP Frontend SDK provides built-in support for custom authentication through thecustomAuth configuration option.
React integration
For React applications, useCDPHooksProvider or CDPReactProvider with the customAuth configuration:
Non-React integration
For vanilla JavaScript/TypeScript or other frameworks, use theinitialize method from @coinbase/cdp-core:
The
getJwt callback is called automatically by CDP whenever authentication is needed. It should return a fresh JWT from your Identity Provider or undefined if the user is not authenticated.Authentication flow
Once you’ve configured custom authentication, you need to explicitly authenticate the user with CDP after they log in with your Identity Provider.Triggering authentication
After your user logs in with your IDP (Auth0, Firebase, etc.), callauthenticateWithJWT() to authenticate with CDP:
- First-time users: CDP will create a new embedded wallet for the user (based on their
subclaim) - Returning users: CDP will retrieve their existing wallet (using the same
subclaim)
Accessing wallet data
Once authenticated with CDP, you can access the user’s wallet:Monitoring authentication state
Use theuseIsSignedIn hook to monitor authentication state:
Session management
Custom authentication sessions differ from CDP’s built-in authentication in several key ways:Token lifecycle
- Managed by your Identity Provider: Session duration, token expiration, and refresh are controlled by your Identity Provider
- Always fresh: CDP calls
getJwtwhenever it needs authentication, ensuring tokens are always current - No CDP refresh: CDP does not store or refresh tokens, it relies entirely on your
getJwtcallback - Maximum TTL: JWTs must have an expiration time (
exp) within 7 days from issuance
Sign out
When using custom authentication, users must sign out from both your Identity Provider and CDP:Testing and debugging
Verify JWT structure
Before integrating with CDP, verify your JWT contains the required claims:- Obtain a JWT from your Identity Provider
- Decode it using jwt.io or similar tool
- Verify claims:
iss: Matches your configured issuersub: Contains a unique, stable user IDexp: Token expiration is in the futureiat: Token issuance timestampaud: Matches your configured audience
Validate JWKS endpoint
Ensure your JWKS endpoint is accessible and returns valid keys:- Access your JWKS URL in a browser (e.g.,
https://example.auth0.com/.well-known/jwks.json) - Verify the response contains public keys
Complete example
A complete working example with Auth0 integration will later be added here.
What to read next
- Authentication Methods: Overview of all authentication options
- Session Management: Understanding session lifecycle with custom auth
- Implementation Guide: General authentication implementation patterns
- Security Configuration: Configure domain allowlisting
- Best Practices: Security recommendations and production readiness