# Get Authorization Api Token

**URL:** <https://community.auth0.com/t/get-authorization-api-token/116590>\
**Category:** Get Help\
**Tags:** management-api\
**Created:** [September 19, 2023, 12:33pm UTC](https://community.auth0.com/t/get-authorization-api-token/116590 "2023-09-19T12:33:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![auth0-ikearg](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@auth0-ikearg](https://community.auth0.com/u/auth0-ikearg)\
**Post date:** [September 19, 2023, 12:33pm UTC](https://community.auth0.com/t/get-authorization-api-token/116590/1 "2023-09-19T12:33:45Z")

</div>

**Hi, I need help with a development to get an authorization token for my user CRUD. I am removing a user first from auth0 and then from my database(with a try catch) but for that I need the authorization token and I am passing it manually because I am having problems to get it with the API.**  
**My current code with the jwt set manually:**

```auto
export const deleteUser = async (id) => {
    try {

        const auth0Endpoint = `https://dev-domain.us.auth0.com/api/v2/users/auth0|${id}`;
        const auth0Headers = new Headers();

        auth0Headers.append("Authorization", `Bearer MyAccessTokenHardcoded`);

        const requestOptions = {
            method: 'DELETE',
            headers: auth0Headers,
            redirect: 'follow'
        };

        // Realiza la solicitud de eliminación en Auth0
        const auth0Response = await fetch(auth0Endpoint, requestOptions);

        // Verifica si la eliminación en Auth0 fue exitosa
        if (auth0Response.status === 204) {
            // Si la eliminación en Auth0 fue exitosa, elimina el usuario en tu base de datos
            const response = await interceptor.delete(`/${id}`);
            return response.data;
        } else {
            console.log('Error al eliminar usuario en Auth0:', auth0Response.statusText);
        }
    } catch (error) {
        console.log(error);
    }l
};

```

_This works but it is not efficient to have to keep updating my token._  
_The token that is working for me is in: Api’s → Auth0 Managment Api → Api explorer_

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [September 19, 2023, 9:31pm UTC](https://community.auth0.com/t/get-authorization-api-token/116590/3 "2023-09-19T21:31:40Z")

</div>

Hey there @auth0-ikearg!

Good to know you’ve got this working manually setting the Management API token, that’s a good start!

You’ll want to take a look at the docs on [obtaining Management API Access tokens](https://auth0.com/docs/secure/tokens/access-tokens/get-management-api-access-tokens-for-production) for production - In particular, I recommend looking at [node-Auth0](https://github.com/auth0/node-auth0) , the node Management API client.

---

<div class="post-metadata">

**Author:** ![auth0-ikearg](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@auth0-ikearg](https://community.auth0.com/u/auth0-ikearg)\
**Post date:** [September 20, 2023, 3:19pm UTC](https://community.auth0.com/t/get-authorization-api-token/116590/4 "2023-09-20T15:19:32Z")

</div>

Hey @ty.frith!  
Thank you for guiding me on this path. I am looking at the links that you just send me. They are very useful.  
My problem is that I am not using a backend for auth0. Everything is in my React application and when I want to get the token I get some errors in the request usually **status 500**. I already activated the cors in my application panel. **I don’t know if I need to create a different api to request this token from my application or if I can request the default “Auth0 Management API”.**

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [September 26, 2023, 11:27pm UTC](https://community.auth0.com/t/get-authorization-api-token/116590/5 "2023-09-26T23:27:23Z")

</div>

No problem, happy to help where I can!

> [@auth0-ikearg](#):
>
> My problem is that I am not using a backend for auth0. Everything is in my React application and when I want to get the token I get some errors in the request usually **status 500**. I already activated the cors in my application panel.

If you do not have a backend to handle Management API tokens, then you will be [limited in terms of which scopes are able to be requested](https://auth0.com/docs/secure/tokens/access-tokens/get-management-api-tokens-for-single-page-applications). The reason being that a a front-end application cannot securely store a token, credentials, etc. Please see our documentation on [confidential and public applications](https://auth0.com/docs/get-started/applications/confidential-and-public-applications).

Typically, you would use a backend to proxy requests like delete a user:

[https://community.auth0.com/t/how-can-i-enable-users-to-change-their-email-address-from-a-spa-or-native-app/44064](https://community.auth0.com/t/how-can-i-enable-users-to-change-their-email-address-from-a-spa-or-native-app/44064)

You can find an example of what that might look like [here](https://github.com/tyfrth/auth0-react-samples-proxy/blob/master/Sample-01/api-server.js).

---

<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:** [October 10, 2023, 11:27pm UTC](https://community.auth0.com/t/get-authorization-api-token/116590/6 "2023-10-10T23:27:29Z")

</div>

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