# How to validate the jwt on server?

**URL:** <https://community.auth0.com/t/how-to-validate-the-jwt-on-server/113811>\
**Category:** Get Help\
**Tags:** new-universal-login-experience, login-experience\
**Created:** [August 17, 2023, 3:53am UTC](https://community.auth0.com/t/how-to-validate-the-jwt-on-server/113811 "2023-08-17T03:53:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ywj79310](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ywj79310/32/49982_2.png) [@ywj79310](https://community.auth0.com/u/ywj79310)\
**Post date:** [August 17, 2023, 3:53am UTC](https://community.auth0.com/t/how-to-validate-the-jwt-on-server/113811/1 "2023-08-17T03:53:07Z")

</div>

From client, I sent a RS256 to the server.

In server, I am using [`jsonwebtoken`](https://github.com/auth0/node-jsonwebtoken) to validate it.  
However, it requires a secret key:

```auto
io.use(function(socket, next){
  if (socket.handshake.query && socket.handshake.query.token){
    jwt.verify(socket.handshake.query.token, 'SECRET_KEY', function(err, decoded) {
      if (err) return next(new Error('Authentication error'));
      socket.decoded = decoded;
      next();
    });
  }
  else {
    next(new Error('Authentication error'));
  }    
})

```

How to get the secret key?

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [August 18, 2023, 2:53pm UTC](https://community.auth0.com/t/how-to-validate-the-jwt-on-server/113811/3 "2023-08-18T14:53:31Z")

</div>

Hi @ywj79310,

Welcome to the Auth0 Community!

For an RS256 signed token, you will need the token’s _Public Key_. You can manually add the key to that library, or fetch the JWKS programatically. There are examples of both in the README for that library: [GitHub - auth0/node-jsonwebtoken: JsonWebToken implementation for node.js http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html](https://github.com/auth0/node-jsonwebtoken#readme)

If you are using Auth0, you can find the key following this resource:

> [@Where is the Auth0 public key to be used in jwt.io to verify the signature of a RS256 token?](https://community.auth0.com/t/where-is-the-auth0-public-key-to-be-used-in-jwt-io-to-verify-the-signature-of-a-rs256-token/8455):
>
> We use an Auth0 account. I paste an Auth0-generated token into [JSON Web Tokens - jwt.io](https://jwt.io/#debugger) . It shows me the header and payload but for the VERIFY SIGNATURE section it asks me to paste in a public RSA key or certificate or a private RSA key in order to verify the signature. I can see I have a secret for each client we’ve registered in Auth0. But where I can find, or how can I create, an RSA key or certificate?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [September 1, 2023, 2:54pm UTC](https://community.auth0.com/t/how-to-validate-the-jwt-on-server/113811/4 "2023-09-01T14:54:00Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
