# Token endpoint { error : access\_denied, error\_description : Unauthorized }

**URL:** <https://community.auth0.com/t/token-endpoint-error-access-denied-error-description-unauthorized/75941>\
**Category:** Get Help\
**Created:** [January 6, 2022, 7:05pm UTC](https://community.auth0.com/t/token-endpoint-error-access-denied-error-description-unauthorized/75941 "2022-01-06T19:05:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![claude\_hasler](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/claude_hasler/32/13280_2.png) [@claude\_hasler](https://community.auth0.com/u/claude_hasler)\
**Post date:** [January 6, 2022, 7:05pm UTC](https://community.auth0.com/t/token-endpoint-error-access-denied-error-description-unauthorized/75941/1 "2022-01-06T19:05:53Z")

</div>

Im trying to implement an oauth client for a mobile device using the PKCE flow. I created a client just for testing. When I try to get the token from the token endpoint I always end up with this error message as a response:

{"error":"access\_denied","error\_description":"Unauthorized"}

My initial request to login is made to this URL:  
[https://dev-m4d-o5x8.eu.auth0.com/authorize?response\_type=code&code\_challenge=BQ8HN\_gme9TyBeJKKfPsh8b5nO8nujAynlFXdXWE-M8&code\_challenge\_method=S256&client\_id=LmmnYyqkKY9yDbhuzQ2f4gpvNGGKLnsT&redirect\_uri=deeplinkscheme://deeplinkexample.com&scope=offline&audience=https://myApi.com&state=AGh14GTZsdf45](https://dev-m4d-o5x8.eu.auth0.com/authorize?response_type=code&code_challenge=BQ8HN_gme9TyBeJKKfPsh8b5nO8nujAynlFXdXWE-M8&code_challenge_method=S256&client_id=LmmnYyqkKY9yDbhuzQ2f4gpvNGGKLnsT&redirect_uri=deeplinkscheme://deeplinkexample.com&scope=offline&audience=https://myApi.com&state=AGh14GTZsdf45)

from which i receive the response, after logging in:  
{code: ukfRo0wbB\_xA4gCy, state: AGh14GTZsdf45}

I then use this code to make an access token request:  
[https://dev-m4d-o5x8.eu.auth0.com/oauth/token?grant\_type=authorization\_code&code\_verifier=VL88D.LaqeB3XVbKYU2yMoA0.8q1OMJpvVF33dt4I1BWD0ipgW7lDRrxdNhgPDLaZSf.kSoN-kKjL96HvL2\_pR8wA3h7OtitMpjmXz0lEMsWD0fO9IjWGXtSIqRlb6XA&code=ukfRo0wbB\_xA4gCy&client\_id=LmmnYyqkKY9yDbhuzQ2f4gpvNGGKLnsT&redirect\_uri=deeplinkscheme://deeplinkexample.com](https://dev-m4d-o5x8.eu.auth0.com/oauth/token?grant_type=authorization_code&code_verifier=VL88D.LaqeB3XVbKYU2yMoA0.8q1OMJpvVF33dt4I1BWD0ipgW7lDRrxdNhgPDLaZSf.kSoN-kKjL96HvL2_pR8wA3h7OtitMpjmXz0lEMsWD0fO9IjWGXtSIqRlb6XA&code=ukfRo0wbB_xA4gCy&client_id=LmmnYyqkKY9yDbhuzQ2f4gpvNGGKLnsT&redirect_uri=deeplinkscheme://deeplinkexample.com)

In the auth0 dashboard i have created an API with the identifier [https://myApi.com](https://myApi.com) and I have an application with the client\_id LmmnYyqkKY9yDbhuzQ2f4gpvNGGKLnsT set the Native.

I cant see what Im doing wrong, can someone help me out?

---

<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:** [January 6, 2022, 10:58pm UTC](https://community.auth0.com/t/token-endpoint-error-access-denied-error-description-unauthorized/75941/3 "2022-01-06T22:58:38Z")

</div>

Hi @claude_hasler,

Thanks for reaching out to the Auth0 Community!

After looking closely at your `/authorize` and `/oauth/token` requests, there does not seem to be anything wrong. I have even inspected your tenant and found that your application uses the correct client ID and application type (Native).

One thing I did notice was your scope was set to `offline` but I believe you want `offline_access` to get refresh tokens.

I have tested the Authorization Code Flow with PKCE and could get it to return an access token. I also managed to reproduce your issue, only by providing an incorrect `client_id` or if I did not specify certain headers in the `/oauth/token` request.

Now, because of that, could you please clarify how you made your request to the `/oauth/token` endpoint?

For example, in Postman I executed the following request:

```auto
curl --location --request POST 'https://MY_DOMAIN.REGION.auth0.com/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'client_id=MY_CLIENT_ID' \
--data-urlencode 'code=IyU6BXCMsIuC6fECwhk4CO6knBEf6J8LXYeJjQi2rzb00' \
--data-urlencode 'code_verifier=rI_Sk2hFhS89hCw4Q69G2hxT4RWfmCIRnIhZqBnPIgbtK7jck_ewFmV.H.o22BNII-A~Lta4fZyEQnp70Rdp7Luyh17rV4lB4bQvHMM.RfSqs5LaRZiS8J36826F_mtw' \
--data-urlencode 'redirect_uri=http://localhost:3000'

```

Looking forward to your response.

Thanks.

---

<div class="post-metadata">

**Author:** ![claude\_hasler](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/claude_hasler/32/13280_2.png) [@claude\_hasler](https://community.auth0.com/u/claude_hasler)\
**Post date:** [January 7, 2022, 4:07pm UTC](https://community.auth0.com/t/token-endpoint-error-access-denied-error-description-unauthorized/75941/4 "2022-01-07T16:07:35Z")

</div>

thanks for the response. I was POSTing with all parameters in the query. I have now switched to the adding the parameters in the body with the ‘Content-Type: application/x-www-form-urlencoded’ header. Access token is now being received. Thank you very much. 🙂

Is this noted anywhere that the parameters must be passed in the body as opposed the query? Or is this more of a POST convention being applied?

---

<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:** [January 7, 2022, 4:38pm UTC](https://community.auth0.com/t/token-endpoint-error-access-denied-error-description-unauthorized/75941/5 "2022-01-07T16:38:30Z")

</div>

Hi @claude_hasler,

Thank you for your response, and I’m happy that it’s working now!

> [@claude\_hasler](#):
>
> Is this noted anywhere that the parameters must be passed in the body as opposed the query? Or is this more of a POST convention being applied?

Sure, it is defined in the [Add Login Using the Authorization Code Flow with PKCE](https://auth0.com/docs/get-started/authentication-and-authorization-flow/add-login-using-the-authorization-code-flow-with-pkce#post-to-token-url-example) and [https://auth0.com/docs/api/authentication#authorization-code-flow-with-pkce45](https://auth0.com/docs/api/authentication#authorization-code-flow-with-pkce45) docs.

Please don’t hesitate to reach out if you have any further questions.

Thank you!

---

<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:** [January 22, 2022, 4:38pm UTC](https://community.auth0.com/t/token-endpoint-error-access-denied-error-description-unauthorized/75941/6 "2022-01-22T16:38:35Z")

</div>

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