Overview
Auth0 is an enterprise identity platform that uses RS256 signing with JWKS for token verification. This guide shows you how to integrate Auth0 authentication with Revstack.Prerequisites
- An Auth0 account and tenant
- An Auth0 API configured with an audience identifier
- Auth0 access tokens being issued to your frontend application
Installation
Configuration
1. Get your Auth0 credentials
From your Auth0 dashboard:- Go to Applications → APIs
- Select your API
- Note your Identifier (this is your audience)
- Note your Domain (e.g.,
your-tenant.us.auth0.com)
2. Build the auth contract
Create an auth contract using your Auth0 configuration:- Normalizes the domain to HTTPS
- Sets the JWKS URI to
https://your-tenant.us.auth0.com/.well-known/jwks.json - Sets the issuer to
https://your-tenant.us.auth0.com/ - Configures RS256 verification strategy
Verification
Initialize the verifier
Verify tokens
In your API routes or middleware:Token structure
Auth0 JWTs contain standard OIDC claims:Custom claims
If you’ve added custom claims to your Auth0 tokens (via Actions/Rules), you can access them fromsession.claims:
Auth0 requires custom claims to be namespaced with a URL. Learn more in the Auth0 custom claims documentation.
Custom user ID claim
By default, Revstack uses thesub claim as the user ID. If you need to use a different claim:
Complete example
Here’s a full Express.js integration:Environment variables
Store your Auth0 configuration in environment variables:Testing
To test your integration:- Obtain an access token from Auth0 (via your frontend app or Postman)
- Send it in the Authorization header:
Bearer <token> - Verify the token is validated correctly
Troubleshooting
”Issuer mismatch” error
Ensure your Auth0 domain is correct and includes the trailing slash in the issuer. The contract builder handles this automatically.”Invalid signature” error
Verify that:- The token was issued by the correct Auth0 tenant
- The JWKS endpoint is accessible
- The token hasn’t been tampered with
”Audience validation failed” error
Check that:- The
audienceparameter matches your Auth0 API identifier - Your Auth0 application is requesting the correct audience when obtaining tokens
Next steps
Auth Overview
Learn more about JWT verification in Revstack
Error Handling
Handle authentication errors gracefully