# Get/Create Refresh token

**URL:** <https://community.auth0.com/t/get-create-refresh-token/132840>\
**Category:** Get Help\
**Tags:** classic-universal-login-experience, login-experience\
**Created:** [April 26, 2024, 7:00am UTC](https://community.auth0.com/t/get-create-refresh-token/132840 "2024-04-26T07:00:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrick-urbidesk](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@patrick-urbidesk](https://community.auth0.com/u/patrick-urbidesk)\
**Post date:** [April 26, 2024, 7:00am UTC](https://community.auth0.com/t/get-create-refresh-token/132840/1 "2024-04-26T07:00:02Z")

</div>

Hi @marcelina.barycka@dan.woda, @ty.frith, @rueben.tiow , @

how to do if i want to return a refresh token with my access token when i authenticate please?

for example if i try this to get the authorization code:

[https://urbidesk-prod.eu.auth0.com/authorize?audience=https://prod.auth.urbidesk.com&scope=offline\_access&response\_type=code&client\_id=my\_client\_id&redirect\_uri=undefined&state=xyz123ABC](https://urbidesk-prod.eu.auth0.com/authorize?audience=https://prod.auth.urbidesk.com&scope=offline_access&response_type=code&client_id=my_client_id&redirect_uri=undefined&state=xyz123ABC)

i got 400 Bad request

Thanks for advance

---

<div class="post-metadata">

**Author:** ![dawid.matuszczyk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dawid.matuszczyk/32/74550_2.png) [@dawid.matuszczyk](https://community.auth0.com/u/dawid.matuszczyk)\
**Post date:** [April 26, 2024, 11:58am UTC](https://community.auth0.com/t/get-create-refresh-token/132840/2 "2024-04-26T11:58:03Z")

</div>

Hi @patrick-urbidesk

Welcome back to the Auth0 Community!

Thank you for posting your question. I’ve checked the logs for your tenant and see several failed login attempts that are undefined as redirecturi and invalid. Can you try to adjust the redirect\_uri for the application that you are trying and set a proper client\_id from the application list? If you want to access the API from the M2M application, you must Authorize it first in the API-\> select API → Machine to Machine Applications.

[https://auth0.com/docs/secure/tokens/refresh-tokens/get-refresh-tokens](https://auth0.com/docs/secure/tokens/refresh-tokens/get-refresh-tokens)

Thanks  
Dawid

---

<div class="post-metadata">

**Author:** ![patrick-urbidesk](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@patrick-urbidesk](https://community.auth0.com/u/patrick-urbidesk)\
**Post date:** [April 26, 2024, 12:15pm UTC](https://community.auth0.com/t/get-create-refresh-token/132840/3 "2024-04-26T12:15:49Z")

</div>

thanks @dawid.matuszczyk for your response but after applying your suggestion i landed on the signin page of my app and i want to ask how to get the result as a json or something like that but i got full HTML.

My objective is to get the response like that

```auto
{
  "access_token": "eyJz93a...k4laUWw",
  "refresh_token": "GEbRxBN...edjnXbL",
  "id_token": "eyJ0XAi...4faeEoQ",
  "token_type": "Bearer"
}

```

but as the first step i need to get the authorization code by executing this

[https://XXXXXXX/authorize](https://XXXXXXX/authorize)?  
response\_type=code&  
client\_id=my\_cliend\_id&  
redirect\_uri={[https://yourApp/callback](https://yourApp/callback)}&  
scope={scope}&  
state={state}

then use the code into this one

curl --request POST   
–url ‘XXXXXX/oauth/token’   
–header ‘content-type: application/x-www-form-urlencoded’   
–data grant\_type=authorization\_code   
–data ‘client\_id=my\_client\_id’   
–data ‘client\_secret={yourClientSecret}’   
–data ‘code=yourAuthorizationCode}’   
–data ‘redirect\_uri={[https://yourApp/callback](https://yourApp/callback)}’

as in the Auth0 docs or i missed something?

thanks

---

<div class="post-metadata">

**Author:** ![dawid.matuszczyk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dawid.matuszczyk/32/74550_2.png) [@dawid.matuszczyk](https://community.auth0.com/u/dawid.matuszczyk)\
**Post date:** [April 26, 2024, 12:38pm UTC](https://community.auth0.com/t/get-create-refresh-token/132840/4 "2024-04-26T12:38:14Z")

</div>

Yes you are correct!

The code you will get back from the Auth0 as a part of the URL as part of the URL:

> `{https://yourApp/callback}?code=BPPLN3Z4qCTvSNOy`. You can exchange this code with an access token using the `/oauth/token` endpoint.

In the Doc that I’m supposed you are referring to [Get Refresh Tokens](https://auth0.com/docs/secure/tokens/refresh-tokens/get-refresh-tokens#:~:text=oauth/token%20endpoint.-,cURL,-C%23) there are multiple example of getting the access token along refresh token.

Thanks  
Dawid

---

<div class="post-metadata">

**Author:** ![patrick-urbidesk](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@patrick-urbidesk](https://community.auth0.com/u/patrick-urbidesk)\
**Post date:** [April 26, 2024, 12:54pm UTC](https://community.auth0.com/t/get-create-refresh-token/132840/5 "2024-04-26T12:54:07Z")

</div>

@dawid.matuszczyk i have some error like this in my url

##[https://urbidesk.com/?error=access\_denied&error\_description=Service%20not%20found%3A%20urbidesk-prod.eu.auth0.com&state=xyz123ABC##](https://urbidesk.com/?error=access_denied&error_description=Service%20not%20found%3A%20urbidesk-prod.eu.auth0.com&state=xyz123ABC##)

when i with this

[https://urbidesk-prod.eu.auth0.com/authorize?audience=urbidesk-prod.eu.auth0.com&scope=offline\_access&response\_type=code&client\_id=my\_client\_id&redirect\_uri=https://urbidesk.com&state=xyz123ABC](https://urbidesk-prod.eu.auth0.com/authorize?audience=urbidesk-prod.eu.auth0.com&scope=offline_access&response_type=code&client_id=my_client_id&redirect_uri=https://urbidesk.com&state=xyz123ABC)

---

<div class="post-metadata">

**Author:** ![dawid.matuszczyk](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dawid.matuszczyk/32/74550_2.png) [@dawid.matuszczyk](https://community.auth0.com/u/dawid.matuszczyk)\
**Post date:** [April 26, 2024, 1:16pm UTC](https://community.auth0.com/t/get-create-refresh-token/132840/6 "2024-04-26T13:16:05Z")

</div>

I’ve double check with your tenant and the audience may be incorrect. It should be the Identifier from the API settings.

---

<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:** [May 10, 2024, 1:16pm UTC](https://community.auth0.com/t/get-create-refresh-token/132840/7 "2024-05-10T13:16:19Z")

</div>

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