# How to validate token in Node.js Hemera?

**URL:** <https://community.auth0.com/t/how-to-validate-token-in-node-js-hemera/9093>\
**Category:** Get Help\
**Tags:** nodejs, validate, token, token-validation, access-token\
**Created:** [December 30, 2017, 3:05am UTC](https://community.auth0.com/t/how-to-validate-token-in-node-js-hemera/9093 "2017-12-30T03:05:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![codemonkey2012](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/codemonkey2012/32/7547_2.png) [@codemonkey2012](https://community.auth0.com/u/codemonkey2012)\
**Post date:** [December 30, 2017, 3:05am UTC](https://community.auth0.com/t/how-to-validate-token-in-node-js-hemera/9093/1 "2017-12-30T03:05:34Z")

</div>

I need to figure out how to validate a token generated from auth0 for a non-express/non-hapi node microservice. The quickstart samples that use the express implementation for node-jwks-rsa are not really an option here, as this is a hemera service. so for this code:

```
this.hemera.use(hemeraJwt, {
      enforceAuth: true,
      jwt: { secret: 'test' }
    })  

```

how can I retrieve the jwt secret for the hemeraJwt to decode the token?

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [January 2, 2018, 7:55pm UTC](https://community.auth0.com/t/how-to-validate-token-in-node-js-hemera/9093/2 "2018-01-02T19:55:17Z")

</div>

From the code snippet you seem to be using `hemera-jwt-auth` [library](https://github.com/hemerajs/hemera/tree/master/packages/hemera-jwt-auth) which is then using `node-jsonwebtoken` [library](https://github.com/auth0/node-jsonwebtoken) to perform the actual validation of the tokens.

Based on that and assuming `secret` is being passed directly to `node-jsonwebtoken` [method](https://github.com/auth0/node-jsonwebtoken#jwtverifytoken-secretorpublickey-options-callback) `verify` then the value of that option should be:

> secretOrPublicKey is a string or buffer containing either the secret for HMAC algorithms, or the PEM encoded public key for RSA and ECDSA.

In conclusion, if the API you configured in Auth0 uses `HS256` then you should pass the signing secret available in the settings. If it uses `RS256` you need to obtain the PEM encoded public key of the signing key used to issue `RS256` tokens. You can obtain that information from the `https://{your_domain}.auth0.com/.well-known/jwks.json` endpoint or directly by downloading the PEM public key at `https://{your_domain}.auth0.com/pem`. the first is the recommend way as that endpoint is defined as part of standards while the seconds is Auth0 specific endpoint.

---

<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:** [March 2, 2018, 5:57am UTC](https://community.auth0.com/t/how-to-validate-token-in-node-js-hemera/9093/3 "2018-03-02T05:57:59Z")

</div>


