# Access token request error: Error: Request failed with status code 401

**URL:** <https://community.auth0.com/t/access-token-request-error-error-request-failed-with-status-code-401/109962>\
**Category:** Get Help\
**Tags:** custom-database-connections, connections\
**Created:** [June 26, 2023, 2:27pm UTC](https://community.auth0.com/t/access-token-request-error-error-request-failed-with-status-code-401/109962 "2023-06-26T14:27:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![elster](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/elster/32/14596_2.png) [@elster](https://community.auth0.com/u/elster)\
**Post date:** [June 26, 2023, 2:27pm UTC](https://community.auth0.com/t/access-token-request-error-error-request-failed-with-status-code-401/109962/1 "2023-06-26T14:27:19Z")

</div>

Dear experts,

I am trying to get a custom DB connected. The DB is accessible via an API protected by an Auth0 M2M application. Using Postman, I can authenticate against the Auth0 application to get an access token for the API call. However, when I use exactly the same request within the custom DB login script, I get the error mentioned in the topic title.  
Here is the axios call I use to authenticate and the axios interceptor output for the request (uppercase words are placeholders):

```auto
  axios.post('https://AUTH0_TENANT_URL/oauth/token', {
    grant_type: 'client_credentials',
    audience: 'AUTH0_API_ID',
    client_id: 'AUTH0_M2M_APP_CLIENT_ID',
    client_secret: 'AUTH0_M2M_APP_CLIENT_SECRET'
	}, {
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
})

```

```auto
4:11:02 PM:
 Starting Request {
"transformRequest": {},
"transformResponse": {},
"headers": {
"common": {
"Accept": "application/json, text/plain, */*"
},
"patch": {
"Content-Type": "application/x-www-form-urlencoded"
},
"post": {
"Content-Type": "application/x-www-form-urlencoded"
},
"put": {
"Content-Type": "application/x-www-form-urlencoded"
},
"Content-Type": "application/x-www-form-urlencoded"
},
"timeout": 0,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"method": "post",
"url": "https://AUTH0_TENANT_URL/oauth/token",
"data": {
"grant_type": "client_credentials",
"audience": "AUTH0_API_ID",
"client_id": "AUTH0_M2M_APP_CLIENT_ID",
"client_secret": "AUTH0_M2M_APP_CLIENT_SECRET"
}
}

```

Thanks in advance for your expertise,  
Elmar

---

<div class="post-metadata">

**Author:** ![elster](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/elster/32/14596_2.png) [@elster](https://community.auth0.com/u/elster)\
**Post date:** [June 26, 2023, 4:10pm UTC](https://community.auth0.com/t/access-token-request-error-error-request-failed-with-status-code-401/109962/2 "2023-06-26T16:10:13Z")

</div>

Fixed. It was a duplicate of this issue [https://community.auth0.com/t/error-at-requesting-management-api-access-token-for-production-using-node-js/52354](https://community.auth0.com/t/error-at-requesting-management-api-access-token-for-production-using-node-js/52354)

---

<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 26, 2023, 5:24pm UTC](https://community.auth0.com/t/access-token-request-error-error-request-failed-with-status-code-401/109962/3 "2023-06-26T17:24:24Z")

</div>

Thanks for sharing a follow up!

---

<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 10, 2023, 5:24pm UTC](https://community.auth0.com/t/access-token-request-error-error-request-failed-with-status-code-401/109962/4 "2023-07-10T17:24:43Z")

</div>

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