# Get refresh token when requesting client credentials

**URL:** <https://community.auth0.com/t/get-refresh-token-when-requesting-client-credentials/111184>\
**Category:** JWT.io\
**Tags:** api\
**Created:** [July 13, 2023, 10:45am UTC](https://community.auth0.com/t/get-refresh-token-when-requesting-client-credentials/111184 "2023-07-13T10:45:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![omar.elsafwany](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/omar.elsafwany/32/48847_2.png) [@omar.elsafwany](https://community.auth0.com/u/omar.elsafwany)\
**Post date:** [July 13, 2023, 10:45am UTC](https://community.auth0.com/t/get-refresh-token-when-requesting-client-credentials/111184/1 "2023-07-13T10:45:54Z")

</div>

I am currently requesting **client\_credentials** to receive access token and be able to access certain endpoints with it accordingly. The current issue is that the response does not contain **refresh\_token** and from what I understand, I need to send another request to **/authorize** endpoint to generate **code** which is then used to send a request of type **authorization\_code** which includes both **access\_token and refresh\_token.**

The problem is that **/authorize** endpoint renders a form that requires login to generate a code. Is there another way to get that code OR another way in general to both access\_token and refresh\_token?

---

<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:** [July 14, 2023, 4:24pm UTC](https://community.auth0.com/t/get-refresh-token-when-requesting-client-credentials/111184/3 "2023-07-14T16:24:23Z")

</div>

Hi @omar.elsafwany,

Welcome to the Auth0 Community!

The client credentials grant does not support refresh tokens.

I think there may be some confusion though, because it doesn’t sound like you are using client credentials, but rather an auth code.

Could you show us a code snippet of what you are doing?

---

<div class="post-metadata">

**Author:** ![omar.elsafwany](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/omar.elsafwany/32/48847_2.png) [@omar.elsafwany](https://community.auth0.com/u/omar.elsafwany)\
**Post date:** [July 17, 2023, 5:57am UTC](https://community.auth0.com/t/get-refresh-token-when-requesting-client-credentials/111184/4 "2023-07-17T05:57:22Z")

</div>

Hello @dan.woda

The request I am sending is the following

```auto
curl --location 'https://dev-qzbuevkju0f6s5kg.us.auth0.com/oauth/token' \
    --header 'Content-Type: application/json' \
    --header 'Cookie: did=s%3Av0%3A3e94caf0-1e36-11ee-971c-c70c19658b19.S3sBGdMXyfjAH3mcTs1GXoN2YRz7g4dtA4ioZqETAM0; did_compat=s%3Av0%3A3e94caf0-1e36-11ee-971c-c70c19658b19.S3sBGdMXyfjAH3mcTs1GXoN2YRz7g4dtA4ioZqETAM0' \
    --data '{
    "client_id": "client_id",
    "client_secret": "client_secret",
    "audience": "https://brkz.co",
    "grant_type": "client_credentials",
    "scope": "read:private read:protected"
}'

```

and the response is as follows

```auto
{
        "access_token": "access_token",
        "scope": "read:private read:protected",
        "expires_in": 86400,
        "token_type": "Bearer"
    }

```

The thing is with that flow, I am not able to refresh the token once expired. To get `refresh_token`, I would need to call `/authorize` endpoint which renders a login form. Any other way to get the `refresh_token` since I mainly using M2M setup?

N.B. The current application I am working on does not support email/username. The application expects a mobile number and then sends an OTP to the customer. Once the customer inputs the OTP, gains access and proceeds. At that point, i’ll be attempting to generate an access token to send with future requests but would also need a refresh token in case the access expired.

---

<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:** [July 17, 2023, 4:42pm UTC](https://community.auth0.com/t/get-refresh-token-when-requesting-client-credentials/111184/5 "2023-07-17T16:42:11Z")

</div>

@omar.elsafwany,

That is a client credentials grant…but that grant specifically does not support refresh tokens, by design.

> [@omar.elsafwany](#):
>
> N.B. The current application I am working on does not support email/username. The application expects a mobile number and then sends an OTP to the customer. Once the customer inputs the OTP, gains access and proceeds. At that point, i’ll be attempting to generate an access token to send with future requests but would also need a refresh token in case the access expired.

This is _not a M2M flow_. You shouldn’t be sending a M2M (client credentials) token to your user. The user should be requesting their own Access Token from the auth server. Is the OTP login happening through Auth0?

---

<div class="post-metadata">

**Author:** ![omar.elsafwany](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/omar.elsafwany/32/48847_2.png) [@omar.elsafwany](https://community.auth0.com/u/omar.elsafwany)\
**Post date:** [July 18, 2023, 9:20am UTC](https://community.auth0.com/t/get-refresh-token-when-requesting-client-credentials/111184/6 "2023-07-18T09:20:29Z")

</div>

@dan.woda currently it’s not but I am currently considering that. `Passwordless` seems to take care of many things.

---

<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:** [July 18, 2023, 1:45pm UTC](https://community.auth0.com/t/get-refresh-token-when-requesting-client-credentials/111184/7 "2023-07-18T13:45:52Z")

</div>

Yes, I would suggest passwordless to handle your flow.

---

<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:** [August 1, 2023, 1:46pm UTC](https://community.auth0.com/t/get-refresh-token-when-requesting-client-credentials/111184/8 "2023-08-01T13:46:00Z")

</div>

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