JWT Errors
To ensure proper authentication with Web3Auth, it is necessary for the JWT header to have the kid
field, while the payload data should have the iat
field.
When configuring Web3Auth's Custom Authentication, you may encounter JWT errors. Below is a list of these errors and the necessary steps to resolve them.
- Invalid JWT Verifiers ID field
- Error occurred while verifying params could not verify identity
- Failed to verify JWS signature
- Error occurred while verifying params unable to verify jwt token
- Duplicate Token
- Could not get result from torus nodes Duplicate token found
- Expired Token
- Error occurred while verifying paramstimesigned is more than 1m0s ago
- Mismatch JWT Validation field
- Refresh Tokens?
Invalid JWT Verifiers ID
field.
Error occurred while verifying params could not verify identity
"Error occurred while verifying params could not verify identity" error could be because the
verifierIdField
of extraLoginOptions
is different from the one you have set up during the
creation of Verifiers (JWT Verifiers ID
) on the Web3Auth dashboard.
-
This is the
JWT Verifiers ID
field on theVerifier Modal
of the Web3Auth dashboard. -
Make sure, this matched with your code.
import { WALLET_ADAPTERS, CHAIN_NAMESPACES } from "@web3auth/base";
await web3auth.connectTo(WALLET_ADAPTERS.AUTH, {
loginProvider: "jwt",
extraLoginOptions: {
domain: "YOUR-AUTH0-DOMAIN",
verifierIdField: "sub", // <-- This is the JWT Verifiers ID field.
response_type: "token",
scope: "email profile openid",
},
});
Failed to verify JWS signature.
Error occurred while verifying params unable to verify jwt token
"Error occurred while verifying params unable to verify jwt token" error could be because of the following reasons:
- The verifier for your AuthAdapter might be wrong. Check to make sure the
verifier
field is set correctly. - The JWT is not signed with the correct key(JWK).
- The JWKS endpoint is not reachable or doesn't return a valid JWK that was used to sign the JWT.
- The JWKS endpoint is incorrect on the Web3Auth Dashboard. Double check to confirm the correct JWKS
endpoint.
- The JWKS is missing the
kid
field. - The
kid
present in the JWT header is not present in the JWKS.
sample jwks
:
{
"keys": [
{
"kty": "RSA",
"e": "AQAB",
"use": "sig",
"kid": "YOUR-KID", // <-- This is the kid.
"n": "YOUR-N",
"alg": "RS256" // <-- This is the algorithm.
}
]
}
sample jwks endpoint
: https://www.googleapis.com/oauth2/v3/certs
Duplicate token
Could not get result from torus nodes Duplicate token found
-
"Could not get result from torus nodes Duplicate token found" error is thrown when the JWT is sent twice in the same request.
await web3auth.connectTo(WALLET_ADAPTERS.AUTH, {
loginProvider: "jwt",
extraLoginOptions: {
id_token: "ID_TOKEN", // <-- JWT should be unique for each request.
verifierIdField: "sub",
},
});