# JWT decode issue in Spring Boot

**URL:** <https://community.auth0.com/t/jwt-decode-issue-in-spring-boot/89851>\
**Category:** Get Help\
**Tags:** jwt, spring-security\
**Created:** [September 1, 2022, 12:02pm UTC](https://community.auth0.com/t/jwt-decode-issue-in-spring-boot/89851 "2022-09-01T12:02:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hantsy](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/hantsy/32/29176_2.png) [@hantsy](https://community.auth0.com/u/hantsy)\
**Post date:** [September 1, 2022, 12:02pm UTC](https://community.auth0.com/t/jwt-decode-issue-in-spring-boot/89851/1 "2022-09-01T12:02:04Z")

</div>

In my spring Boot (2.7.3) application, I used Auth0/Spring Security to protect our backend APIs, but we encountered an exception like this when deploying into our staging environment.

```bash
2022-09-01 11:29:33.096 DEBUG 1 --- [or-http-epoll-1] o.s.s.w.s.a.AuthenticationWebFilter : 
Authentication failed: An error occurred while attempting to decode the Jwt: class 
com.nimbusds.jose.JWEHeader cannot be cast to class com.nimbusds.jose.JWSHeader 
(com.nimbusds.jose.JWEHeader and com.nimbusds.jose.JWSHeader are in unnamed module of 
loader org.springframework.boot.loader.LaunchedURLClassLoader @43da41e)

```

Which caused the decoding jwt does not work. Not sure where is wrong in my config. I use Auth0/Spring before but not encountered this issue.

I just configured an issuerUri in Spring Security resource server to discover the Oauth/Oidc config, I need to use other config in Auth0, eg. jwsUris , publicKeyUri etc.

---

<div class="post-metadata">

**Author:** ![hantsy](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/hantsy/32/29176_2.png) [@hantsy](https://community.auth0.com/u/hantsy)\
**Post date:** [September 6, 2022, 7:47am UTC](https://community.auth0.com/t/jwt-decode-issue-in-spring-boot/89851/2 "2022-09-06T07:47:43Z")

</div>

Finally, we found the frontend developer did not setup the auth0 audience.

But why auth0 return a wrong generated jwt token, not give a notice to developer that it is lack of audience ?

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [November 1, 2024, 4:12pm UTC](https://community.auth0.com/t/jwt-decode-issue-in-spring-boot/89851/4 "2024-11-01T16:12:10Z")

</div>

Hi @hantsy,

Yes, what you have observed is called an opaque token. This happens when the Auth0 audience is omitted from the authorization request. The token is still valid but is not considered a JWT token.

To generate a JWT token, you must specify the `audience` query parameter in the authorization request.

The telltale sign that the access token is not a JWT is when the `audience` is omitted, and you can’t decode it on [jwt.io](http://jwt.io). Instead, it only works against the [`/user info endpoint](https://auth0.com/docs/api/authentication#get-user-info).

Thanks,  
Rueben

---

<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:** [November 15, 2024, 4:12pm UTC](https://community.auth0.com/t/jwt-decode-issue-in-spring-boot/89851/5 "2024-11-15T16:12:27Z")

</div>

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