/oauth/device/code endpoint error unauthorized_client


I’m trying out some POST calls in Postman. I can get it to work with in my terminal with curl but not Postman (or Axios request in an app).

What works with curl:

  curl --request POST \
  --url 'https://{DEVICE_AUTH_URL_123}/oauth/device/code' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data 'client_id={CLIENT_ID_123}&scope=openid&audience=AUDIENCE_URL_123'

What doesn’t work in Postman:

Error I get in Auth0 logs:

  "body": {},
  "qs": {
    "client_id": "CLIENT_ID_123",
    "scope": "openid",
    "audience": "AUDIENCE_URL_123"
  "error": {
    "message": "Unauthorized or unknown client",
    "oauthError": "unauthorized_client",
    "type": "oauth-authorization"

Appreciate any help I can get!


Did you put “DEVICE_AUTH_URL_123”, “CLIENT_ID_123” and “AUDIENCE_URL_123” in your Postman request like that just for the example ? Because device auth url and client id you put in your Curl are variables, but don’t seem to be such in Postman.
Also, have you ensured your application in Auth0 has device code grant type enabled ?

Edit : I just noticed something : you put client id, scope and audience as parameters, but you have to add these in the body, in “x-www-form-urlencoded” !

Thanks for your reply!

I did not put “DEVICE_AUTH_URL_123”, “CLIENT_ID_123” and “AUDIENCE_URL_123” in Postman, I put actual values.

As for headers, Content-Type: application/x-www-form-urlencoded is set in Postman as well.

Have you tried putting client_id, scope and audience in the request body like I asked in my post edit ? I noticed you had put these as parameters before, but I think the API is waiting for a body.

That was it, thank you! :slight_smile:

It appears to have been a change in behaviour. Not sure if it’s on Auth0 or Axios.

I have an app running in prod for two years which added the client id etc as url params and not body.

Used axios 0.2.4. But when I did a minor bump of Axios, I got this error but still had the same code.

So for reference, if somebody encouter this problems, move the variables from params to body!

1 Like

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