How to authorize application for management API with API

Under the UI dashboard, Applications → Auth0 Management API (Test Application) → APIs I can authorize other APIs.
How do I do this using the API? I didn’t see an API call or field for it.

Thank you!

Hello there @meaganh !

It’s not necessarily documented, but you can do so as mentioned in this topic:

A quick script utilizing the Node Management Client that creates a client and authorize an API + scopes might look like:

const ManagementClient = require('auth0').ManagementClient;
require('dotenv').config();

const management = new ManagementClient({
    domain: process.env.AUTH0_DOMAIN,
    clientId: process.env.AUTH0_CLIENT_ID,
    clientSecret: process.env.AUTH0_CLIENT_SECRET,
    scope: 'create:clients create:client_grants' // ensure you have these scopes in your token
});

const clientData = {
  name: 'node-test-app',
  app_type: 'non_interactive', //must be non_interactive (m2m)
  // include other client options here as necessary
};

management.createClient(clientData)
  .then(client => {
    console.log('Created client', client);

    const clientGrant = {
      client_id: client.client_id,
      audience: 'https://test-api-endpoint',
      scope: ['read:msg', 'create:msg'],
    };

    return management.createClientGrant(clientGrant);
  })
  .then(clientGrant => {
    console.log('Created client grant', clientGrant);
  })
  .catch(err => {
    console.error('Error creating client or client grant', err);
  });

Hope this helps!

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