Get Management API Token in actions (SPA)


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:

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

var options = {
  method: 'POST',
  url: '',
  headers: {'content-type': 'application/x-www-form-urlencoded'},
  data: {
    grant_type: 'client_credentials',
    client_id: 'xxxxx',
    client_secret: 'xxxxx',
    audience: ''

axios.request(options).then(function (response) {
}).catch(function (error) {

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

Anyone knows why this happens?

Hi @tauli,

Welcome to the Community!

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

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.

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