Having no problem making a CURL but receive "BAD_AUDIENCE" when going through Python

Using the example in API doc

curl -H "Authorization: Bearer {My_Token}" https://{My_tenant}.auth0.com/api/v2/clients

Just to get the clients’ info. This works.

When I go through Python, though

url = urlparse.urljoin(My_tenant, 'api/v2/clients')
headers = {"Authorization": My_Token}
response = requests.get(url, headers=headers)

and I got {u'message': u'Bad audience: https://{My_Tenant}.auth0.com/api/v2/', u'error': u'Unauthorized', u'statusCode': 401}

I double checked my token in jwt.io and it’s just fine. It has all the permission. Why do I receive this message? I’m doing a GET, how do I pass the audience param (usually in -d) to the call?

Note that I’m implementing this through an API, so I’m calling something that’s not https://{My_Tenant}.auth0.com/api/v2/, say, http://localhost:8000, but should redirect to https://{My_Tenant}.auth0.com/api/v2/ with correct credential

Is that the issue?

Ah I figured it out. I was actually using another domain when calling the management API. My bad.

Glad you eventually figured this one out!

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