# Empty JWT payload in accessToken is not valid

**URL:** <https://community.auth0.com/t/empty-jwt-payload-in-accesstoken-is-not-valid/115302>\
**Category:** JWT.io\
**Tags:** jwt, api, access-token\
**Created:** [September 4, 2023, 5:07am UTC](https://community.auth0.com/t/empty-jwt-payload-in-accesstoken-is-not-valid/115302 "2023-09-04T05:07:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex2020](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/alex2020/32/48638_2.png) [@alex2020](https://community.auth0.com/u/alex2020)\
**Post date:** [September 4, 2023, 5:07am UTC](https://community.auth0.com/t/empty-jwt-payload-in-accesstoken-is-not-valid/115302/1 "2023-09-04T05:07:13Z")

</div>

Hello,  
I’m using react sdk, the login works and I get an accessToken. But when I want to use this accessToken with my backend (C#) it doens’t work. When I check the token using [jwt.io](http://jwt.io) I get the warning “Looks like your JWT payload is not a valid JSON object. JWT payloads must be top level JSON objects as per  
[RFC 7519 - JSON Web Token (JWT)](https://tools.ietf.org/html/rfc7519#section-7.2)”

I already have the api audience in the login call:  
loginWithRedirect({  
authorizationParams: {  
audience: “[http://localhost:5268/](http://localhost:5268/)”  
},  
});

And then I use “getAccessTokenSilently” to get the access token. And finally I add the access token as a bearer token to the api request.

This is my accessToken:  
eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIiwiaXNzIjoiaHR0cHM6Ly9kZXYtZ2ZpcmNlNHUwZ2loMGd2dy51cy5hdXRoMC5jb20vIn0…5OCR8HUSoFSYd3x6.OrLuo7JOeBj9GetnupHMYefcSu-WnePkhfRzk-efCapjLfbPM8sTDwZS3HeOVMI1uaDKPKbt7ilnuLBDSVo747KVTiMFulRJJhXFM69VMHw6xP5v\_6rP0LII\_CZjEY3PTZHrmWEL9DkKpOzewLEhNf2h3KIPHn6RW8Txb9SWh7N1WOU\_XGaCz19Fuye-rDT\_n6MfAH3pyjYBFXFKpwvK8W1zheMYpG8d7fdaOdsYV8wq-ApnDs0kKFhUGz\_\_xINT2alFPuuLlAAnhogLphHFMgQ4ONboOtIk1Oj1z1lT3WQcIBQFf8X6LcQCWNvYjSURxlPG60x5OFXrFYcfZ-mPSeOX.8tHPP63eddlX6VlI7qraVg

What am I missing? How can I get a valid accessToken with a valid JSON as a payload?

---

<div class="post-metadata">

**Author:** ![alex2020](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/alex2020/32/48638_2.png) [@alex2020](https://community.auth0.com/u/alex2020)\
**Post date:** [September 8, 2023, 5:19am UTC](https://community.auth0.com/t/empty-jwt-payload-in-accesstoken-is-not-valid/115302/3 "2023-09-08T05:19:52Z")

</div>

Anyone from the auth0 can reply to this thread?

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [September 8, 2023, 11:33pm UTC](https://community.auth0.com/t/empty-jwt-payload-in-accesstoken-is-not-valid/115302/4 "2023-09-08T23:33:14Z")

</div>

Hey @alex2020 welcome to the community!

> [@alex2020](#):
>
> loginWithRedirect({  
> authorizationParams: {  
> audience: “[http://localhost:5268/”](http://localhost:5268/%E2%80%9D)  
> },  
> });

I just glanced at your tenant and it looks like `http://localhost:5268/` is indeed registered properly in Auth0. It sounds like this is the access token you are getting via auth0-react in your own app? Have you attempted to reproduce using the [sample app](https://github.com/auth0-samples/auth0-react-samples/tree/master/Sample-01)? I just created an API with the same identifier and am getting a valid non-opaque access token back in the sample app. I recommend giving it a go as it will remove any application specific variables that might be in play here.

Let us know!

---

<div class="post-metadata">

**Author:** ![alex2020](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/alex2020/32/48638_2.png) [@alex2020](https://community.auth0.com/u/alex2020)\
**Post date:** [September 11, 2023, 2:53am UTC](https://community.auth0.com/t/empty-jwt-payload-in-accesstoken-is-not-valid/115302/5 "2023-09-11T02:53:37Z")

</div>

Thanks for your suggestion @ty.frith.  
I tried it with the sample app and it worked. The difference between the sample app and my app was that I was passing the audience to the loginWithRedirect method while the sample app passed this value to the Auth0Provider. After I did this change in my app it started working.  
The documentation on this is not very clear but at least it’s working now 🙂  
Thanks for your help!

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [September 12, 2023, 7:35pm UTC](https://community.auth0.com/t/empty-jwt-payload-in-accesstoken-is-not-valid/115302/6 "2023-09-12T19:35:21Z")

</div>

Ahh, gotcha - Thanks for clarifying! That’s odd that it wasn’t working with `loginWithRedirect` as I believe it should given it’s passed in `authorizationParams`. Regardless, I’m happy to hear you got it working and sorry for the confusion!

---

<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 26, 2023, 7:36pm UTC](https://community.auth0.com/t/empty-jwt-payload-in-accesstoken-is-not-valid/115302/7 "2023-09-26T19:36:02Z")

</div>

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