Skip to main content

Custom JWT Integration

If you already have an authentication system that issues JWTs (Auth0, Firebase Auth, Supabase Auth, Clerk, or a custom backend), you can use the custom_jwt auth method to connect it to Privacy Boost. Your auth system signs the user in and issues a JWT; the SDK sends that JWT to Privacy Boost as part of sign-in, and Privacy Boost verifies it against your JWKS endpoint.

How It Works

Custom JWT Authentication Flow Custom JWT Authentication Flow

Server-Side Setup

Your app must be configured with the custom_jwt auth method. Contact the Privacy Boost team with:
  • JWKS URL — The HTTPS endpoint serving your JSON Web Key Set (e.g., https://your-auth.com/.well-known/jwks.json). Privacy Boost fetches this to verify JWT signatures.
  • Audience — Required expected aud claim in your JWTs. Only tokens with a matching audience are accepted.
  • Issuer — Required expected iss claim in your JWTs. Only tokens with a matching issuer are accepted.
The backend configuration looks like:

JWT Requirements

Your JWT must:
  • Be signed with RS256, RS384, RS512, ES256, ES384, or ES512
  • Include a kid (Key ID) header matching a key in your JWKS
  • Include a sub or user_id claim identifying the user
  • Include an exp claim and be valid (not expired)
  • Match the configured aud and iss

Client-Side Integration

1. Configure Privacy Boost for Direct IdP Auth

In a browser, getExternalToken only works with the local key vault. The default browser key vault runs in an isolated iframe, which can’t call back into your page, so passing getExternalToken there throws. Set keyVault: { mode: 'local' }:
Local mode keeps the user’s keys in your page’s memory, so it gives up the iframe’s isolation: script running on your page, including a compromised dependency, can read the keys or sign with them. Weigh that before choosing custom JWT auth for a browser app.

2. Provide the External JWT

Pass getExternalToken to signIn. It returns the raw JWT from Auth0, Firebase, Supabase, Clerk, or your own auth system. The SDK sends it on both the /auth/login bootstrap and the /auth/token exchange, so it’s called more than once per sign-in and should return a cached token rather than mint a new one each time.
On iOS, Android, and React Native, pass the JWT as the externalToken argument of signIn instead.
Relaying the login through your own backend (tokenProvider) isn’t supported yet.

Testing

For development, an app on App ID only auth signs in without an external token. Switch the app to custom JWT for production.

Next Steps

Continue with setup: Or explore other auth methods:
  • Privy — For Privy social login and embedded wallets
  • Dynamic — For Dynamic wallet connection and embedded wallets
  • API Secret — For your own servers: the Backend API and the CLI