# OAuth token request with basic authentication

**URL:** <https://community.auth0.com/t/oauth-token-request-with-basic-authentication/55783>\
**Category:** Get Help\
**Created:** [January 6, 2021, 2:49pm UTC](https://community.auth0.com/t/oauth-token-request-with-basic-authentication/55783 "2021-01-06T14:49:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mitko.td](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mitko.td/32/26712_2.png) [@mitko.td](https://community.auth0.com/u/mitko.td)\
**Post date:** [January 6, 2021, 2:49pm UTC](https://community.auth0.com/t/oauth-token-request-with-basic-authentication/55783/1 "2021-01-06T14:49:21Z")

</div>

I try the request token with basic authentication but receive an error: Unauthorized. I prepare the authenticated string in this way:

Basic encodebase64(\<client\_id\>:\<client\_secret\>)

Where is my mistake?

---

<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:** [January 6, 2021, 9:18pm UTC](https://community.auth0.com/t/oauth-token-request-with-basic-authentication/55783/3 "2021-01-06T21:18:32Z")

</div>

Hi @mitko.td,

Welcome to the Community!

Are you trying to implement the client credentials flow? This doc goes through implementation step-by-step:

> **[Call Your API Using the Client Credentials Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/call-your-api-using-the-client-credentials-flow)**
>
> Learn how to call your API from a machine-to-machine (M2M) application using the Client Credentials Flow.

---

<div class="post-metadata">

**Author:** ![mitko.td](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mitko.td/32/26712_2.png) [@mitko.td](https://community.auth0.com/u/mitko.td)\
**Post date:** [January 7, 2021, 8:12am UTC](https://community.auth0.com/t/oauth-token-request-with-basic-authentication/55783/4 "2021-01-07T08:12:14Z")

</div>

Hi Dan,

Yes, when client\_id and client\_secret are URL parameters this works, but not in the situation which I described - Basic authentication.  
This option exists in the discovery options which I received by “.well-known” request.

---

<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:** [January 7, 2021, 7:18pm UTC](https://community.auth0.com/t/oauth-token-request-with-basic-authentication/55783/5 "2021-01-07T19:18:36Z")

</div>

Hmm, I got it working using this:

Encode the client ID and secret:

```auto
echo -n 'YOUR_CLIENT_ID:YOUR_CLIENT_SECRET' | base64

```

Send the request:

```auto
curl --request POST \
     --url 'https://example_tenant.auth0.com/oauth/token' \
     --header 'Authorization: Basic BASE64_ENCODED_ID_AND_SECRET' \
     --data 'audience=YOUR_API_IDENTIFIER&grant_type=client_credentials'

```

---

<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 25, 2021, 8:48pm UTC](https://community.auth0.com/t/oauth-token-request-with-basic-authentication/55783/6 "2021-01-25T20:48:21Z")

</div>

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