Client is not authorized to access, You need to create a \"client-grant\" associated to this API

I am trying to get client credentials, but I am getting below error.

URL:
POST: https://domain/oauth/token

Body:
grant_type: client_credentials
client_id:
client_secret:
audience:

Error:


{
    "error": "access_denied",
    "error_description": "Client is not authorized to access \"https://dev-f0x4xlzg.us.auth0.com/api/v2/\". You need to create a \"client-grant\" associated to this API. See: https://auth0.com/docs/api/v2#!/Client_Grants/post_client_grants"
}

Hey there @selvi!

It sounds like the client might not be authorized - You can authorize it by going to Applications → API → Management API → Machine to Machine Applications in your tenant dashboard.

Hope this helps!

1 Like

The above error got resolved, but I am still facing some issue after generating client credential , Using that token I am trying to create a new org, but it throws error

POST https://domain/api/v2/organizations

Content-Type: application/json
Authorization: Bearer …


Error:
{
    "statusCode": 401,
    "error": "Unauthorized",
    "message": "Invalid token",
    "attributes": {
        "error": "Invalid token"
    }
}

Great, good to know the original issue was resolved!

I’ve seen this error crop up when the audience is not set correctly - In this case it needs to be https://YOUR_DOMAIN.auth0.com/api/v2/

Aside from that, I’d check to make sure the correct permissions (create:organizations) are assigned to the M2M app. You can find some details on that here:

1 Like

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