# Getting 401 UNAUTHORIZED on /oauth/token call Spring Boot

**URL:** <https://community.auth0.com/t/getting-401-unauthorized-on-oauth-token-call-spring-boot/109966>\
**Category:** Get Help\
**Tags:** classic-universal-login-experience, login-experience\
**Created:** [June 26, 2023, 2:52pm UTC](https://community.auth0.com/t/getting-401-unauthorized-on-oauth-token-call-spring-boot/109966 "2023-06-26T14:52:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![csira](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/csira/32/47492_2.png) [@csira](https://community.auth0.com/u/csira)\
**Post date:** [June 26, 2023, 2:52pm UTC](https://community.auth0.com/t/getting-401-unauthorized-on-oauth-token-call-spring-boot/109966/1 "2023-06-26T14:52:05Z")

</div>

Using SpringBoot to evaluate using Auth0 for our setup and we get through most of the authentication process in the logs until it gets to the point of trying to call /oauth/token

At that point, we are getting back 401 UNAUTHORIZED

Note: the sample app seems to work just fine with the same server and configuration parameters, but we cannot determine why auth0 would be returning 401 error code for this call.

```auto
Start processing with input [code=owexrHqOpynPpfu7IG-9jig-tUBJbIWpcyQF3cnsdoe3D&state=NVq7-pWcfxtCM5xme7JDB6Y3YKjDVdDatWc4AP8xDnE%3D]
HTTP POST https://votedown.us.auth0.com/oauth/token
Accept=[application/json, application/*+json]
Writing [{grant_type=[authorization_code], code=[owexrHqOpynPpfu7IG-9jig-tUBJbIWpcyQF3cnsdoe3D], redirect_uri=[http://localhost:3002/login/oauth2/code/auth0]}] as "application/x-www-form-urlencoded;charset=UTF-8"
sun.net.www.MessageHeader@54352a858 pairs: {POST /oauth/token HTTP/1.1: null}{Accept: application/json;charset=UTF-8}{Content-Type: application/x-www-form-urlencoded;charset=UTF-8}{Authorization: Basic MXRTQ0NsRFBKc0lEREdYd2gzand0SmFoRTJONUFYTnA6JTNEdGFEdjRVUFdyRUR3ODFwY09NYzdHMWNaZTh6QjBIRm02QVpBUXhhVm1YazlXdm9UQzU3Q093VnF4TnppWHl3cg==}{User-Agent: Java/1.8.0_265}{Host: votedown.us.auth0.com}{Connection: keep-alive}{Content-Length: 155}
sun.net.www.MessageHeader@5786448125 pairs: {null: HTTP/1.1 401 Unauthorized}{Date: Mon, 26 Jun 2023 14:41:57 GMT}{Content-Type: application/json}{Content-Length: 60}{Connection: keep-alive}{CF-Ray: 7dd636d049d343c3-EWR}{CF-Cache-Status: DYNAMIC}{Cache-Control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0, no-transform}{Set-Cookie: did=s%3Av0%3A9a400790-142f-11ee-9010-3d579083fb35.PAbYu%2BbW3phmKzzbEVAOXlCD7vJlar3QGAFmqcjS%2BLQ; Max-Age=31557600; Path=/; Expires=Tue, 25 Jun 2024 20:41:57 GMT; HttpOnly; Secure; SameSite=None}{Strict-Transport-Security: max-age=31536000}{Vary: Origin}{ot-baggage-auth0-request-id: 7dd636d049d343c3}{ot-tracer-sampled: true}{ot-tracer-spanid: 290b6f672964277b}{ot-tracer-traceid: 265903064263393e}{Set-Cookie: did_compat=s%3Av0%3A9a400790-142f-11ee-9010-3d579083fb35.PAbYu%2BbW3phmKzzbEVAOXlCD7vJlar3QGAFmqcjS%2BLQ; Max-Age=31557600; Path=/; Expires=Tue, 25 Jun 2024 20:41:57 GMT; HttpOnly; Secure}{traceparent: 00-0000000000000000265903064263393e-290b6f672964277b-01}{tracestate: auth0-request-id=7dd636d049d343c3,auth0=true}{X-Auth0-RequestId: fc096012e214db03bb3f}{X-Content-Type-Options: nosniff}{X-RateLimit-Limit: 300}{X-RateLimit-Remaining: 299}{X-RateLimit-Reset: 1687790519}{Server: cloudflare}{alt-svc: h3=":443"; ma=86400}
Response 401 UNAUTHORIZED
Redirecting to /login?error

```

---

<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:** [June 28, 2023, 6:55pm UTC](https://community.auth0.com/t/getting-401-unauthorized-on-oauth-token-call-spring-boot/109966/3 "2023-06-28T18:55:37Z")

</div>

Hi @csira,

Could you please share the code you are using to make the call? I’m seeing a `Basic` auth in the snippet you posted, and I don’t think that should be there.

---

<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:** [July 26, 2023, 3:21pm UTC](https://community.auth0.com/t/getting-401-unauthorized-on-oauth-token-call-spring-boot/109966/4 "2023-07-26T15:21:53Z")

</div>

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