Auth0 Home Blog Docs

"Bad audience" error in /api/v2/tickets/email-verification

auth0
api
management-api
#1

Calling https://rwehresmann.auth0.com/api/v2/tickets/email-verification results in the following error:

{
    "statusCode": 401,
    "error": "Unauthorized",
    "message": "Bad audience: survivorbet.com https://rwehresmann.auth0.com/userinfo"
}

Any idea of what am I doing wrong?

#3

Hey there @rwehresmann!

Are you sure you’re using the right tenant name in your call? It might be the main reason that affect your audience .

When it comes to the request

{
  "client_id":"clientID",
  "client_secret":"XXXX",
  "grant_type":"client_credentials", 
  "audience":"https://[tenant].eu.auth0.com/api/v2/"
}

Let me know if that helps!

#4

Hello @konrad.sopala, thanks for the reply!

You’re right, I changed but now I receive "Insufficient scope, expected any of: create:user_tickets". However, my Auth0 Management API have this scope defined. What should be my next step?

And I would like to ask: api/v2/tickets/email-verification will always go for Auth0 Management API? The error I had before was happening because I tryied to use the audience of a custom API that I created in my Auth0 account.

#5

Hey @rwehresmann!

Sorry for one thing my bad, didn’t check your tenant region. So instead of
"audience":"https://[tenant].eu.auth0.com/api/v2/"

you should go for:
“audience”:“https://[tenant].us.auth0.com/api/v2/”

in

{
  "client_id":"clientID",
  "client_secret":"XXXX",
  "grant_type":"client_credentials", 
  "audience":"https://[tenant].eu.auth0.com/api/v2/"
}

What is more I think you’re using the wrong access token in the Management API. The survivorbet.com/userinfo is not the Management API, it’s probably some other API you have defined right?

The core here is that you’re probably logging in, getting a regular access token and using it with the Management API.

Hope it helps!

#6

Hey there @rwehresmann!

Have you been able to check out what I’ve provided up there in the meantime?

Let me know if you need further help!

closed #7