Can't get access token for client

I can’t get access token for my client in application
My request

const token: any = await axios.post(
        Endpoints.DOMAIN + Endpoints.GET_ACCESS_TOKEN,
        {
            grant_type: 'client_credentials',
            client_id: process.env.AUTH0_CLIENT_ID,
            client_secret: process.env.AUTH0_CLIENT_SECRET,
            audience: Endpoints.DOMAIN + Endpoints.V2,
        },
        {
            headers: {
                'content-type': 'application/json',
            }
        }
    )

Request in documentation

  url: 'https://domain/oauth/token',
  headers: { 'content-type': 'application/json' },
  body: '{"client_id":"client_id","client_secret":"client_secret","audience":"https://domain/api/v2/","grant_type":"client_credentials"}' };

Hi @ph1 ,

What’s the error response you get back from the /oauth/token endpoint?

1 Like

Hi @supun,
Request:

data: {
      error: 'unauthorized_client',
      error_description: "Grant type 'client_credentials' not allowed for the client.",
      error_uri: 'https://auth0.com/docs/clients/client-grant-types'
    }

Hi @ph1 ,

Thank you for the response.

To use the client_credentials grant with your application, first you need to enable it for the application.

You can enable the client_credentials grant for your application by navigating to Applications → Select Your Application → Settings → Advanced Settings (bottom of the page) → Grant Types

1 Like

Did you have a fix on this issue? Facing same issue but no response from anyone. mcdvoice

The problem was not solved, since I use a machine to machine connection, and this type is enabled there

Hi @ph1,

To further investigate, could you kindly DM me your tenant name and client id?

Thanks!

1 Like

Hi supun,
To use the client_credentials grant with your application, first you need to enable it for the application.

You can enable the client_credentials grant for your application by navigating to Applications → Select Your Application → Settings → Advanced Settings (bottom of the page) → Grant Types
for this we cant do every time for every time created applications. Is their any settings to do manually enable grant types in advance settings.
please response soon!!!

Thanks and Regards
Soubhagya

Hi @soubhagya ,

Welcome to the Auth0 Community!

I’m afraid, there’s no Dashboard UI setting available to pre-set the enabled grant types for newly created applications. However, if you use the Auth0 Management API to create applications, you can set the enabled grant types at the time of application creation.

Hope this helps!

1 Like

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