Receiving 401 for "Bad audience" when attempting to get a user

I am creating a management API token using the following:

            const client = new AuthenticationClient({
                domain: <string>this.configService.get('auth0.domain'),
                clientId: this.configService.get('auth0.managementClientId'),
                clientSecret: this.configService.get('auth0.managementClientSecret'),

            const token = await client.clientCredentialsGrant({
                audience: '<audience>',

and then attempting to request a user with this token with the following

        const managementClient = new ManagementClient({
            domain: <string>this.configService.get('auth0.domain'),
            token: token.access_token,
            audience: '<audience>',

        const auth0User = managementClient.getUser({
            id: authId,

However, I receive the following error:

{"statusCode":401,"error":"Unauthorized","message":"Bad audience: <audience>"}

The value of <audience> matches in all of the relevant locations, correctly matches the API identifier, and my server to server application has access to that API, so I’m really at a bit of a loss as to what is going on here

Hello @jakeb welcome to the community!

What audience are using? Do you mind sharing that here?


Forgot to reply here, the issue was that I was using the audience for one of my custom APIs instead of the predefined system API, got that sorted already. Thanks though!

1 Like

Great! That was my suspicion :slight_smile: Thanks for confirming with the community!

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