Create a Custom JWT Auth Server
Learn how to integrate your auth backend with our in-app wallets solution so you can onboard your users into web3 seamlessly.
This guide will show you how to create your own Auth Server that is compatible with the JWT auth strategy. By doing so, you can have full control over user authentication and data security. This allows you to ensure that your application meets specific compliance requirements while also providing a customized sign-in experience.
-
Create a new directory for your project and navigate to it in your CLI
-
Initialize a new Node.js application
-
Install the necessary packages
-
-
To generate a private and a public key run
-
To create the output file run
-
-
Display the public key:
-
Copy the displayed public key.
-
Convert your public key to a JWK using an online JWK Creator tool. We recommend using JWK Creator by Russel Davies.
- Paste the public key, set Key ID as
0
(arbitrary string, must match when signing JWT), and then note down the generated JWK.
- Paste the public key, set Key ID as
-
Create a
jwks.json
in the project root and place the generated JWK in akeys
array.
-
-
In the
jw-auth-server
directory, create a file at the root namedserver.js
and paste the following: -
Replace
http://your-domain.com
with the actual domain for the application.
-
-
Start the server:
-
Test login:
-
Test JWKS:
-
-
Navigate to Wallets > In-App Wallets in the thirdweb dashboard.
-
Create a thirdweb API key if you don't have one or select an existing key to use for this project. Learn more about API keys.
-
Allowlist domain or bundle IDs in Access Restrictions.
-
Navigate to the Configuration view and enable Custom JSON Web Token
-
Set the JWKS URI to
your-domain/.well-known/jwks.json
-
Set the AUD to
EpicGame
or the value you set as theaud
in theserver.js
file. -
Copy the client ID.
-
In your preferred thirdweb client SDK, pass the JWT you retrieved from logging in to the server.
-
A persistent, cross-platform wallet is now created for your user.