# How to authorize application for management API with API

**URL:** <https://community.auth0.com/t/how-to-authorize-application-for-management-api-with-api/110109>\
**Category:** Get Help\
**Tags:** resource-servers, management-api\
**Created:** [June 27, 2023, 8:05pm UTC](https://community.auth0.com/t/how-to-authorize-application-for-management-api-with-api/110109 "2023-06-27T20:05:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![meaganh](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/meaganh/32/42375_2.png) [@meaganh](https://community.auth0.com/u/meaganh)\
**Post date:** [June 27, 2023, 8:05pm UTC](https://community.auth0.com/t/how-to-authorize-application-for-management-api-with-api/110109/1 "2023-06-27T20:05:17Z")

</div>

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!

---

<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:** [June 28, 2023, 1:00am UTC](https://community.auth0.com/t/how-to-authorize-application-for-management-api-with-api/110109/3 "2023-06-28T01:00:48Z")

</div>

Hello there @meaganh !

> [@meaganh](#):
>
> How do I do this using the API? I didn’t see an API call or field for it.

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

> [@Create application/client and authorize for APIs using Management API](https://community.auth0.com/t/create-application-client-and-authorize-for-apis-using-management-api/19744/9):
>
> @ofjansen The page @konrad.sopala linked has what you are looking for slight_smile There is a section ([Update Grant Types](https://auth0.com/docs/api-auth/config/using-the-management-api#authorize-the-application)) on how to authorize an Application for a given API (audience) using the Management API ([Auth0 Management API v2](https://auth0.com/docs/api/management/v2#!/Client_Grants/post_client_grants)). This is what you’re looking for. We use something along the lines of (Node.js SDK): return ManagementClient.createClient(params) .then((client) =\> { ManagementClient.createClientGrant({ client\_id: client.client\_id, audience: audience, …

A quick script utilizing the [Node Management Client](https://www.npmjs.com/package/auth0) that creates a client and authorize an API + scopes might look like:

```auto
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!

---

<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 12, 2023, 1:00am UTC](https://community.auth0.com/t/how-to-authorize-application-for-management-api-with-api/110109/4 "2023-07-12T01:00:53Z")

</div>

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