# Token verification on server side

**URL:** <https://community.auth0.com/t/token-verification-on-server-side/9076>\
**Category:** Get Help\
**Tags:** access\_token, java, verification\
**Created:** [December 28, 2017, 5:08pm UTC](https://community.auth0.com/t/token-verification-on-server-side/9076 "2017-12-28T17:08:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![priya.sharma.9362](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/priya.sharma.9362/32/14302_2.png) [@priya.sharma.9362](https://community.auth0.com/u/priya.sharma.9362)\
**Post date:** [December 28, 2017, 5:08pm UTC](https://community.auth0.com/t/token-verification-on-server-side/9076/1 "2017-12-28T17:08:55Z")

</div>

I am trying to verify access tokens from Auth0, using the Java SDK

my question is whether it is fine to extract the Kid from the token itself and then get the public key based on that kid.

Or we should store the kid locally and use it every time for token verification.

---

<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:** [December 28, 2017, 8:11pm UTC](https://community.auth0.com/t/token-verification-on-server-side/9076/2 "2017-12-28T20:11:48Z")

</div>

The `kid` allows the issuer to signal a key change to the consumer; for example, if you’re obtaining the public key by making a request to the keys endpoint then you could cache the result until you receive a JWT with a different `kid` value. At this time you would try to obtain the keys again in order to check if new keys are available that match the newly received `kid`.

In conclusion, is fine to extract the `kid` from the token and retrieve the key based on that value as long as the request to obtain the keys correctly ensures that is talking to the trusted issuer (the endpoint is served by HTTPS so the client should validate the server certificate).

However, this claim is just an hint so ignoring and always using an hardcoded key it’s also technically possible.

---

<div class="post-metadata">

**Author:** ![priya.sharma.9362](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/priya.sharma.9362/32/14302_2.png) [@priya.sharma.9362](https://community.auth0.com/u/priya.sharma.9362)\
**Post date:** [December 28, 2017, 10:07pm UTC](https://community.auth0.com/t/token-verification-on-server-side/9076/3 "2017-12-28T22:07:26Z")

</div>

Thanks for the help @jmangelo!

---

<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/token-verification-on-server-side/9076/4 "2018-03-02T05:57:57Z")

</div>


