Authenticate with JWT
This tutorial demonstrates how to create and apply a JSON Web Token (JWT) to authenticate an
eth_blockNumber
API request
with Node.js.
Developers can configure the expiry time and scope of JWTs to enhance the security profile of their dapps.
Prerequisites
- Node version 20+
- A text editor (for example, VS Code)
- An Infura account
Steps
1. Initiate your project
Create a new directory for your project:
mkdir infura-jwt-demo
Next, change into the infura-jwt-demo
directory:
cd infura-jwt-demo
Initialize a new Node.js project:
npm init -y
Install the required dependencies:
npm install axios jsonwebtoken dotenv