# Bug: 401/Unauthorized when obtaining token in Authorization Code grant

**URL:** <https://community.auth0.com/t/bug-401-unauthorized-when-obtaining-token-in-authorization-code-grant/131335>\
**Category:** Get Help\
**Tags:** configuration, application\
**Created:** [April 5, 2024, 1:29pm UTC](https://community.auth0.com/t/bug-401-unauthorized-when-obtaining-token-in-authorization-code-grant/131335 "2024-04-05T13:29:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xenoterracide](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/xenoterracide/32/13241_2.png) [@xenoterracide](https://community.auth0.com/u/xenoterracide)\
**Post date:** [April 5, 2024, 1:29pm UTC](https://community.auth0.com/t/bug-401-unauthorized-when-obtaining-token-in-authorization-code-grant/131335/1 "2024-04-05T13:29:10Z")

</div>

> [@401/Unauthorized when obtaining token in Authorization Code grant](https://community.auth0.com/t/401-unauthorized-when-obtaining-token-in-authorization-code-grant/44685):
>
> When using the react-auth0-spa.js and the auth0-spa-js, I have to go through an awkward sequence to make my Authorization Code grant work successfully. I’m suspicious it has nothing to do with auth0-spa-js. In short, creating a user works fine, obtaining the “code” works fine. However; when I try to exchange the code for a token via /oauth/token, I’m getting a 401/Unauthorized. I’m not really calling /oauth/token directly of course, I’m using auth0FromHook.handleRedirectCallback(). I can m…

I had this same problem yesterday. Same workaround fixed it.

---

<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:** [April 5, 2024, 5:26pm UTC](https://community.auth0.com/t/bug-401-unauthorized-when-obtaining-token-in-authorization-code-grant/131335/3 "2024-04-05T17:26:59Z")

</div>

Hi @xenoterracide,

Thanks for letting us know about this issue.

I have not been able to reproduce this issue. However, I am glad you were able to work around this problem by going into the dashboard and changing the **Application Type** from Single Page Application to Regular Web Application, then switching the **Authentication Method** from POST to None, then switching Application Type back to Single Page Application.

Keep us posted if this continues to happen.

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:** [April 19, 2024, 5:27pm UTC](https://community.auth0.com/t/bug-401-unauthorized-when-obtaining-token-in-authorization-code-grant/131335/4 "2024-04-19T17:27:00Z")

</div>

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