Search code examples
node.jsauth0json-web-token

Nodejs reduce jsonwebtoken length


I am beginner in nodejs . I am using jsonwebtokens using nodejs for making login system. Can some one tell me on what parameters the length of token generated depends. Does it only depends on secret string used or any other parameter as well. Also how can we reduce the size of the token generated. Righ now for what I have made it generates token of around 1100 characters.


Solution

  • Auth0 Engineer Here,

    Most part of your JWT will depend on the claims you add to your JWT, with Auth0 you can specify scopes when you are authenticating. These scopes will add the required fields to your JWT. There will be atleast iat, exp, iss, aud and sub claim in a JWT issued by Auth0. Which correspond to issued at, expiration time, issuer, audience and subject claims. Beyond that you can control what scopes you want using the scope parameter. More on this is documented at https://auth0.com/docs/scopes