# Get Management API Token in actions (SPA)

**URL:** <https://community.auth0.com/t/get-management-api-token-in-actions-spa/65112>\
**Category:** Get Help\
**Tags:** management-api\
**Created:** [June 26, 2021, 4:06am UTC](https://community.auth0.com/t/get-management-api-token-in-actions-spa/65112 "2021-06-26T04:06:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tauli](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/tauli/32/26244_2.png) [@tauli](https://community.auth0.com/u/tauli)\
**Post date:** [June 26, 2021, 4:06am UTC](https://community.auth0.com/t/get-management-api-token-in-actions-spa/65112/1 "2021-06-26T04:06:53Z")

</div>

Hi

I’m new to auth0 and I’m getting an “unauthorized” error when calling the management api.

I’ve created a login/post login action which calls the management api using the pre generated code:

```auto
var axios = require("axios").default;

var options = {
  method: 'POST',
  url: 'https://xxxxx.eu.auth0.com/oauth/token',
  headers: {'content-type': 'application/x-www-form-urlencoded'},
  data: {
    grant_type: 'client_credentials',
    client_id: 'xxxxx',
    client_secret: 'xxxxx',
    audience: 'https://xxxxx.eu.auth0.com/api/v2/'
  }
};

axios.request(options).then(function (response) {
  console.log(response.data);
}).catch(function (error) {
  console.error(error);
});

```

This gives me an HTTP 401 error.  
My application is a SPA

Anyone knows why this happens?

---

<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:** [June 28, 2021, 7:48pm UTC](https://community.auth0.com/t/get-management-api-token-in-actions-spa/65112/3 "2021-06-28T19:48:39Z")

</div>

Hi @tauli,

Welcome to the Community!

Can you post the entire error? Usually, you will see something like:

```auto
401	Unauthorized	{"error": "invalid_client", "error_description": "..."}

```

A 401 means there is something about your request that is _Unauthorized_. It could mean that the Client ID or Secret is incorrect, or that the client isn’t authorized for the management API. The error message should help to determine what is not working.

---

<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:** [July 13, 2021, 7:49pm UTC](https://community.auth0.com/t/get-management-api-token-in-actions-spa/65112/4 "2021-07-13T19:49:02Z")

</div>

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