JWT-based auth
Overview
Privy supports all JWT-based authentication providers. This includes any OIDC compliant authentication system, including OAuth 2.0, Auth0, Firebase, AWS Cognito, and more.
Using JWT-based authentication integration, you can use your existing authentication system with Privy’s services. This approach allows users to maintain their existing login experience while giving them access to embedded wallets.
Privy’s authentication is fully compatible with any authentication provider that supports JWT-based, stateless authentication. When a user logs into your app, your auth provider issues them an access and/or identity token to represent their auth status. Privy validates this token to authenticate your user.
Setting Up JWT-Based Authentication
To integrate your JWT-based auth provider with Privy:
- Go to the
- Select your app from the App Dropdown in the left sidebar
- Navigate to the Dashboard via User management > Authentication > JWT-based auth
You’ll need to provide the following information:
Privy requires a verification key to ensure the JWTs received are valid. Both the token’s signature and its expiration time ( claim) are verified to ensure secure access. This verification process helps protect user data and prevents unauthorized access to Privy services.
You can provide the verification key in one of two ways:
Enter the claim from your user’s JWT that contains the user’s unique ID. In most access tokens and identity tokens, this is the claim.
Usage
Implementation
To integrate JWT-based authentication with Privy in your React application, you’ll need to create a custom PrivyProvider
wrapper that supplies your auth token to Privy.
Create a custom PrivyProvider
wrapper
Create a component that wraps the PrivyProvider
with your custom auth configuration:
Integrate the provider with your app
Make sure to nest your custom provider inside your auth provider in your app structure:
Accessing User Authentication Status
Once configured, you can access the user’s authentication status through the Privy SDK:
When using a custom authentication provider, you should not use the Privy login
method (from useLogin
or usePrivy
). Instead, call the login method of your custom provider, and the Privy SDK will automatically synchronize its state.