# 401 Unauthorized Post /oauth/token using Resource Owner Flow

**URL:** <https://community.auth0.com/t/401-unauthorized-post-oauth-token-using-resource-owner-flow/78613>\
**Category:** Get Help\
**Tags:** password, api, login\
**Created:** [February 20, 2022, 2:33am UTC](https://community.auth0.com/t/401-unauthorized-post-oauth-token-using-resource-owner-flow/78613 "2022-02-20T02:33:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ibrahimsam96](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ibrahimsam96/32/35279_2.png) [@ibrahimsam96](https://community.auth0.com/u/ibrahimsam96)\
**Post date:** [February 20, 2022, 2:33am UTC](https://community.auth0.com/t/401-unauthorized-post-oauth-token-using-resource-owner-flow/78613/1 "2022-02-20T02:33:44Z")

</div>

Express App:6001, React App:3000 .

```auto
  var data = {
    grant_type: 'password',
    client_id:'----------------------',
// client_secret: '---------------',
    audience: 'https://dev-49v8whrc.us.auth0.com/api/v2/',
    // scope: "read:sample",
    password: req.body.password,
    username: req.body.username,
  }

axios.post('https://dev-49v8whrc.us.auth0.com/oauth/token', data, {

    headers: { 'content-type': 'application/x-www-form-urlencoded' },

  }).then((response: any) => {

    res.json(response)

    console.log(response)

  }).catch((error: any) => {

    res.json(error.response.data)

    console.log(error.response)

  });

```

I’m sure of the user credentials and client\_id. I signed up the user using the sign-up endpoint and it works. Also tried including secret and audience keys. Unsure how I’m receiving the error, any hint in what I’m doing wrong? It also works on the debugger but not on my app ;/

---

<div class="post-metadata">

**Author:** ![SaqibHussain](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/saqibhussain/32/42924_2.png) [@SaqibHussain](https://community.auth0.com/u/SaqibHussain)\
**Post date:** [February 20, 2022, 10:10am UTC](https://community.auth0.com/t/401-unauthorized-post-oauth-token-using-resource-owner-flow/78613/2 "2022-02-20T10:10:50Z")

</div>

Hey @ibrahimsam96,

Thanks for getting in touch with us at Auth0 Community.

I note that you have client secret commented out, this will need to be present. I tested with the curl below successfully:

```auto
curl --request POST \
  --url 'https://YOUR_DOMAIN/oauth/token' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data grant_type=password \
  --data 'client_id=eLltTv5EmEXOBeZDrjMa4VjGVVVXgc3o' \
  --data 'client_secret=YOUR_CLIENT_SECRET' \
  --data 'audience=https://YOUR_DOMAIN/api/v2/' \
  --data username=USERNAME \
  --data password=PASSWORD

```

Let me know if you’re still having issues.

Warm regards.

---

<div class="post-metadata">

**Author:** ![ibrahimsam96](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ibrahimsam96/32/35279_2.png) [@ibrahimsam96](https://community.auth0.com/u/ibrahimsam96)\
**Post date:** [February 20, 2022, 4:33pm UTC](https://community.auth0.com/t/401-unauthorized-post-oauth-token-using-resource-owner-flow/78613/3 "2022-02-20T16:33:01Z")

</div>

> [@SaqibHussain](#):
>
> Let me know if you’re still having issues.

I’m having the same problem whether I include the secret or not.

In the Resource Owner Password Flow - Only the grant\_type,client\_id,username,password are required.  
[https://auth0.com/docs/api/authentication#resource-owner-password](https://auth0.com/docs/api/authentication#resource-owner-password)

What application type I should select for the above endpoint to work?. Currently in the api debugger, Machine to Machine with None for the token endpoint works but unfortunately returns an error when I run it from my app

---

<div class="post-metadata">

**Author:** ![SaqibHussain](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/saqibhussain/32/42924_2.png) [@SaqibHussain](https://community.auth0.com/u/SaqibHussain)\
**Post date:** [February 20, 2022, 8:08pm UTC](https://community.auth0.com/t/401-unauthorized-post-oauth-token-using-resource-owner-flow/78613/4 "2022-02-20T20:08:41Z")

</div>

Hi @ibrahimsam96  
I used a native app in my testing, does it work if you run your parameters as a curl statement as per my example, this will help troubleshoot the issue, also ensure the password grant is enabled on your client?

Look forward to hearing from you.  
Warm regards.

---

<div class="post-metadata">

**Author:** ![fernando.torres](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/fernando.torres/32/36748_2.png) [@fernando.torres](https://community.auth0.com/u/fernando.torres)\
**Post date:** [May 31, 2022, 4:08am UTC](https://community.auth0.com/t/401-unauthorized-post-oauth-token-using-resource-owner-flow/78613/5 "2022-05-31T04:08:32Z")

</div>

Hello everyone,

I had this problem, and noticed that in Postman or with cURL I received the access token with no problems, while when I was trying with Node (axios) it did not work. I stumbled across [this](https://community.auth0.com/t/resource-owner-password-flow-works-fine-with-postman-but-throws-401-unauthorised-with-axios-node-js/68537), and just deleting the headers in the request fixed the issue.

Regards,

Fernando

---

<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:** [May 31, 2022, 11:55am UTC](https://community.auth0.com/t/401-unauthorized-post-oauth-token-using-resource-owner-flow/78613/6 "2022-05-31T11:55:43Z")

</div>

Thanks for sharing that with the rest of community!

---

<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:** [July 28, 2022, 10:30am UTC](https://community.auth0.com/t/401-unauthorized-post-oauth-token-using-resource-owner-flow/78613/7 "2022-07-28T10:30:45Z")

</div>


