# Refresh Management API Token

**URL:** <https://community.auth0.com/t/refresh-management-api-token/121955>\
**Category:** Get Help\
**Tags:** management-api, roles\
**Created:** [November 29, 2023, 5:34pm UTC](https://community.auth0.com/t/refresh-management-api-token/121955 "2023-11-29T17:34:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![crimsonartpanda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/crimsonartpanda/32/52845_2.png) [@crimsonartpanda](https://community.auth0.com/u/crimsonartpanda)\
**Post date:** [November 29, 2023, 5:34pm UTC](https://community.auth0.com/t/refresh-management-api-token/121955/1 "2023-11-29T17:34:35Z")

</div>

I am totally lost on how to refresh my management API token as whenever it expires I receive this error: “Error: 401 Client Error: Unauthorized for url:” whenever I attempt to read my user roles. Also, would this management API handling happen within on action or within my application code?

---

<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:** [November 29, 2023, 7:00pm UTC](https://community.auth0.com/t/refresh-management-api-token/121955/3 "2023-11-29T19:00:10Z")

</div>

Hi @crimsonartpanda,

Welcome to the Auth0 Community!

If you need to get refresh your Management API token, I recommend performing the client credentials grant flow to obtain an access token. See [Get Management API Access Tokens for Production](https://auth0.com/docs/secure/tokens/access-tokens/get-management-api-access-tokens-for-production).

Additionally, there is a good explanation about this in a related post as well:

> [@Best practice for refreshing token for Auth0 Management API](https://community.auth0.com/t/best-practice-for-refreshing-token-for-auth0-management-api/6944/2):
>
> The recommended practice for your scenario is to obtain the access token to call the Management API by performing a [client credentials grant](https://auth0.com/docs/api-auth/grant/client-credentials). This grant does not imply or require user credentials, it obtains a token by providing only client application credentials (id and secret). In addition, have in mind that this grant can only be used by confidential client applications that are able to maintain the assigned secret secret. You’re using this from a back-end so that certainly qualifies as a c…

I hope this helps!

Please let me know if you have any questions.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![crimsonartpanda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/crimsonartpanda/32/52845_2.png) [@crimsonartpanda](https://community.auth0.com/u/crimsonartpanda)\
**Post date:** [November 29, 2023, 9:55pm UTC](https://community.auth0.com/t/refresh-management-api-token/121955/4 "2023-11-29T21:55:51Z")

</div>

Thank you so much for the reply! I am currently using the " Example: Python implementation" and it seems to be using client credentials as the grant type, grabbing the access token with a post request, and then accessing another endpoint with a get request. If I understand correctly, does this required grabbing of the access token almost work like a refresh in a way, protecting against API expiration?

---

<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:** [November 30, 2023, 6:09pm UTC](https://community.auth0.com/t/refresh-management-api-token/121955/5 "2023-11-30T18:09:11Z")

</div>

Hi @crimsonartpanda,

Thanks for the reply.

> [@crimsonartpanda](#):
>
> does this required grabbing of the access token almost work like a refresh in a way, protecting against API expiration?

Yes, it does. Essentially, this flow calls for a new access token with a fresh expiration.

Thanks,  
Rueben

---

<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:** [December 14, 2023, 6:09pm UTC](https://community.auth0.com/t/refresh-management-api-token/121955/6 "2023-12-14T18:09:30Z")

</div>

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