Hi.
I’m trying to retrieve an auth token so I can later get user info, using this guide: Get Management API Access Tokens for Production
However, I get a 401 Unauthorized when calling from my React JS client.
I had this working exactly the same code in a previous vanilla JS client, and the equivalent CURL returns a response with a token so I can’t see what’s causing this issue.
I’m posting:
{ "grant_type": "client_credentials", "client_id": xxx, "client_secret": xxx, "audience": "https://shoutapp.eu.auth0.com/api/v2/" };
to ‘https://shoutapp.eu.auth0.com/oauth/token’
and as I say, CURL works:
curl --request POST --url 'https://shoutapp.eu.auth0.com/oauth/token' --header 'content-type: application/json' --data '{"grant_type":"client_credentials","client_id": "xxx","client_secret": "xxx","audience": "https://shoutapp.eu.auth0.com/api/v2/"}'
so the credentials definitely match the machine-to-machine application but the JS call does not. There’s nothing useful in the returned error except “401 unauthorised”