# Resource Owner Password flow only works with headers removed

**URL:** <https://community.auth0.com/t/resource-owner-password-flow-only-works-with-headers-removed/84131>\
**Category:** Get Help\
**Tags:** access\_token, login, auth0\
**Created:** [May 26, 2022, 7:35pm UTC](https://community.auth0.com/t/resource-owner-password-flow-only-works-with-headers-removed/84131 "2022-05-26T19:35:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![peter22](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/peter22/32/37591_2.png) [@peter22](https://community.auth0.com/u/peter22)\
**Post date:** [May 26, 2022, 7:35pm UTC](https://community.auth0.com/t/resource-owner-password-flow-only-works-with-headers-removed/84131/1 "2022-05-26T19:35:56Z")

</div>

Following up on this [old thread here](https://community.auth0.com/t/resource-owner-password-flow-works-fine-with-postman-but-throws-401-unauthorised-with-axios-node-js/68537/7)…

I, too, needed to remove the header attribute (using the node.js with axios call format) that is referenced in several Auth0 docs that explain the Resource Owner Password flow - like [here](https://auth0.com/docs/api/authentication?javascript#resource-owner-password), or [here](https://auth0.com/docs/get-started/authentication-and-authorization-flow/call-your-api-using-resource-owner-password-flow#call-api).

problem header:

`"content-type": "application/x-www-form-urlencoded"`

Can anyone shine a light on why this header fails the call? I only ever receive a 401 HTTP error and a CORS warning:

`Access to XMLHttpRequest at 'https://my_auth_api/oauth/token' from origin 'http://localhost:1234' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.`

Seems like there needs to be an update to the documentation unless I’m really off the mark.

Any insight would be helpful - Thanks!

---

<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:** [May 26, 2022, 8:59pm UTC](https://community.auth0.com/t/resource-owner-password-flow-only-works-with-headers-removed/84131/3 "2022-05-26T20:59:56Z")

</div>

Hi @peter22,

Welcome to the Auth0 Community!

I understand that you encountered issues when making a Resource Owner Password Grant (ROPG) flow request.

I have seen this issue in the past, and it involves fixing the `content-type` in the request to `application/json`.

See below:

```auto
var axios = require("axios").default;

var options = {
  method: 'POST',
  url: 'https://YOUR_DOMAIN.REGION.auth0.com/oauth/token',
  headers: {'content-type': 'application/json'},
  data: {    
    grant_type: "password",
    username: "user@example.com",
    password: "pwd",
    audience: 'YOUR_AUDIENCE_IDENTIFIER',
    scope: 'read:sample',
    client_id: "YOUR_CLIENT_ID",
    client_secret: "YOUR_CLIENT_SECRET"

  }
};

axios.request(options).then(function (response) {
  console.log(response.data);
}).catch(function (error) {
  console.error(error);
});

```

Let me explain further. When using the `"application/x-www-form-urlencoded"` content-type as shown in our documentation, the data gets passed as URL encoded. Meaning that the data is appended to the URL, like below:

```auto
grant_type=password&username=user@example.com&password=pwd&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&audience=YOUR_AUDIENCE&scope=read:sample

```

Whereas the `"application/json"` content type is used for POSTing JSON data.

Hoped this helps!

Please let me know if you have any additional questions.

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 22, 2022, 10:51am UTC](https://community.auth0.com/t/resource-owner-password-flow-only-works-with-headers-removed/84131/4 "2022-12-22T10:51:09Z")

</div>


