# Access Denied when using oauth/token

**URL:** <https://community.auth0.com/t/access-denied-when-using-oauth-token/86039>\
**Category:** Get Help\
**Tags:** auth0\
**Created:** [June 28, 2022, 6:31am UTC](https://community.auth0.com/t/access-denied-when-using-oauth-token/86039 "2022-06-28T06:31:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anton.p](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/anton.p/32/33385_2.png) [@anton.p](https://community.auth0.com/u/anton.p)\
**Post date:** [June 28, 2022, 6:31am UTC](https://community.auth0.com/t/access-denied-when-using-oauth-token/86039/1 "2022-06-28T06:31:58Z")

</div>

const options = {  
method: ‘POST’,  
url: ISS\_AUTH0\_DOMAIN + ‘oauth/token’,  
headers: {‘content-type’: ‘application/json’},  
data: {  
grant\_type: ‘[http://auth0.com/oauth/grant-type/passwordless/otp](http://auth0.com/oauth/grant-type/passwordless/otp)’,  
client\_id: AUTH0\_CLIENT\_ID,  
client\_secret: AUTH0\_CLIENT\_SECRET,  
username: body.username,  
otp: body.code,  
realm: ‘email’,  
scope: ‘openid profile email offline\_access’  
}  
};

Response:  
data: {  
error: ‘access\_denied’,  
error\_description: “Cannot read property ‘length’ of undefined”  
}

---

<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:** [June 28, 2022, 7:07pm UTC](https://community.auth0.com/t/access-denied-when-using-oauth-token/86039/3 "2022-06-28T19:07:18Z")

</div>

Hi @anton.p,

Welcome to the Auth0 Community!

I understand that you encountered an Access Denied error when making a request to the `oauth/token` endpoint.

After looking at your request, there is nothing that stands out to me as an issue. However, the error points out that one of the required data passed in the request was undefined.

In this scenario, I recommend printing the data in your request on console to see if there are any undefined values.

Please let me know how this goes for you.

Thank you.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 21, 2022, 5:11pm UTC](https://community.auth0.com/t/access-denied-when-using-oauth-token/86039/4 "2022-12-21T17:11:53Z")

</div>


