19

I tried using the auth0 postman template to make an authentication request using username and password and I'm getting an unsupported grant type: password error. What am I doing wrong?

var client = new RestClient("https://test.auth0.com/oauth/token");
var request = new RestRequest(Method.POST);
request.AddHeader("postman-token", "abc");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", "grant_type=password&client_id=foo&audience=&username=test&password=test&scope=openid%20email%20picture%20nickname", ParameterType.RequestBody);
3
  • This feature was originally released as part of the work done for OAuth 2.0 API Authorization functionality; you may try to check if you have this functionality enabled in your advanced account settings. If this does not solve it, you should provide more information about your account and client settings. Commented Jan 13, 2017 at 11:33
  • 4
    Ok, now I'm getting Authorization server not configured with default connection error - also what does enabling API in the adv settings do? Don't I already have access to an API? Commented Jan 13, 2017 at 12:23
  • You can configure the default connection in the General tab; check Execute the Resource Owner Password Grant docs for more info. The OAuth 2.0 API Authorization is for when you want to use Auth0 to issue access tokens that then can be used by your own API to make authorization decisions. Commented Jan 13, 2017 at 13:01

3 Answers 3

55
  1. Log into the Auth0 dashboard
  2. Go to account settings (top right under your username)
  3. On the general tab scroll down to the API Authorization Settings section
  4. Default Audience would be your API identifier (if you have an API)
  5. Default Directory would be your connection such as database connection name

In your POST to oauth/token do not include audience (if you specified the default above).

Gotta love how Auth0 makes authentication easy and painfully hard at the same time.

Refer below screenshot as a reference. enter image description here

4
  • 1
    thanks @the-muffin-man, this worked like a charm . BTW, my error was slightly different and it was Authorization server not configured with default connection
    – sameera207
    Commented Jul 4, 2018 at 11:58
  • @sameera207 I'm not surprised. Auth0 seems to change/update their UI relatively frequently. Feel free to update my answer. Commented Jul 8, 2018 at 21:36
  • What if I have two connections? It seems if I set Default Directory as one connection, the other connection will not work. How should I solve this issue? Commented Aug 15, 2018 at 16:52
  • I think this is just a default, so if you don't specify a connection then the default is used. So in your case I believe you'd want to send the value in your POST. I'm not sure what the variable name is in the POST or how you define it. Commented Aug 15, 2018 at 16:54
5

Go to Default App > Settings >

In the bottom of settings, Click {Show Advanced Settings}

Select Grant Types Tab

Check the password which is unchecked by default

Post request to *//oauth/token and it works

enter image description here

1
  • this also has to be done, because by default is not allowed. indeed.
    – lnaie
    Commented Jun 30, 2020 at 21:05
3

These are the exact steps I have taken in order to resolve this exact issue

Login with browser on desktop At top right of UI, click click username, Settings

Scroll down to API Authorization Settings

Enter valid values in BOTH Default Audience, and Default Directory.

For example, for me I already had been using the Lock screen, and had already setup a Default Audience which I was setting in my client application and everything was working.

I also had already setup a Connections > Database, with the name of Username-Password-Authentication.

Here is a screenshot of it working after doing the above, using the postman collection , which at the time of writing, is contained here

https://app.getpostman.com/run-collection/2a9bc47495ab00cda178

which is referenced here

https://auth0.com/docs/api/authentication#code-samples

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.