# getKeyId() return null

**URL:** <https://community.auth0.com/t/getkeyid-return-null/60585>\
**Category:** Get Help\
**Tags:** jwt\
**Created:** [April 6, 2021, 2:49am UTC](https://community.auth0.com/t/getkeyid-return-null/60585 "2021-04-06T02:49:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bariloche](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bariloche/32/28595_2.png) [@bariloche](https://community.auth0.com/u/bariloche)\
**Post date:** [April 6, 2021, 2:49am UTC](https://community.auth0.com/t/getkeyid-return-null/60585/1 "2021-04-06T02:49:30Z")

</div>

Hi all

I am using ` java-jwt:3.15.0` library and it seems it not able to decode the token correctly.

The JWT tokeon on `jwks-rsa-java` github page works as expected. I am able to `jwt.getKeyId()`

```auto
eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IlJrSTVNakk1T1VZNU9EYzFOMFE0UXpNME9VWXpOa1ZHTVRKRE9VRXpRa0ZDT1RVM05qRTJSZyJ9.eyJpc3MiOiJodHRwczovL3NhbmRyaW5vLmF1dGgwLmNvbS8iLCJzdWIiOiJhdXRoMHw1NjMyNTAxZjQ2OGYwZjE3NTZmNGNhYjAiLCJhdWQiOiJQN2JhQnRTc3JmQlhPY3A5bHlsMUZEZVh0ZmFKUzRyViIsImV4cCI6MTQ2ODk2NDkyNiwiaWF0IjoxNDY4OTI4OTI2fQ.NaNeRSDCNu522u4hcVhV65plQOiGPStgSzVW4vR0liZYQBlZ_3OKqCmHXsu28NwVHW7_KfVgOz4m3BK6eMDZk50dAKf9LQzHhiG8acZLzm5bNMU3iobSAJdRhweRht544ZJkzJ-scS1fyI4gaPS5aD3SaLRYWR0Xsb6N1HU86trnbn-XSYSspNqzIUeJjduEpPwC53V8E2r1WZXbqEHwM9_BGEeNTQ8X9NqCUvbQtnylgYR3mfJRL14JsCWNFmmamgNNHAI0uAJo84mu_03I25eVuCK0VYStLPd0XFEyMVFpk48Bg9KNWLMZ7OUGTB_uv_1u19wKYtqeTbt9m1YcPMQ

```

However, when I use [jwt.io](http://jwt.io) token, the `jwt.getKeyId()` is null.  
`eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.POstGetfAytaZS82wHcjoTyoqhMyxXiWdR7Nn7A29DNSl0EiXLdwJ6xC6AfgZWF1bOsS_TuYI3OG85AmiExREkrS6tDfTQ2B3WXlrr-wp5AokiRbz3_oB4OxG-W9KcEEbDRcZc0nH3L7LzYptiy1PtAylQGxHTWZXtGz4ht0bAecBgmpdgXMguEIcoqPJ1n3pIWk_dUZegpqx0Lka21H6XxUTxiy8OcaarA8zdnPUnV6AmNP3ecFawIFYdvJB_cm-GvpCSbr8G8y_Mllj8f4x9nBH8pQux89_6gUY618iYv7tuPWBFfEbLxtF2pZS6YC1aSfLQxeNe8djT9YjpvRZA`

I am not sure what I am doing wrong?

```auto
DecodedJWT jwt = JWT.decode(token); 
JwkProvider provider = new UrlJwkProvider("https://jwks.com/");
Jwk jwk = provider.get(jwt.getKeyId()); // this fails

```

Please see attached screensht  
As you can see in “not working” in header object `getKeyId()` is `null`

 ![not working](https://global.discourse-cdn.com/auth0/original/3X/4/c/4c05eae252c0c43fc97659abe792a9b6ed6adb9f.png)  
Working case  
 ![working](https://global.discourse-cdn.com/auth0/original/3X/0/d/0dfad5e017c5ebdabb8139e554613dc652fff8ca.jpeg)

Note: For some reason `kid` information is not pass in header from our token generating service it is part of payload

---

<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:** [April 6, 2021, 4:29pm UTC](https://community.auth0.com/t/getkeyid-return-null/60585/2 "2021-04-06T16:29:14Z")

</div>

> [@bariloche](#):
>
> However, when I use [jwt.io](http://jwt.io) token, the `jwt.getKeyId()` is null.

The token from [JWT.io](http://JWT.io) you posted does not contain a `kid`. You can decode the tokens on [JWT.io](http://JWT.io) and inspect their contents (header, payload)

---

<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:** [April 21, 2021, 4:29pm UTC](https://community.auth0.com/t/getkeyid-return-null/60585/4 "2021-04-21T16:29:50Z")

</div>

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