How to make a username password request with auth0 custom api, getting error "unsupported grant type: password" error

MonkeyBonkey picture MonkeyBonkey · Jan 13, 2017 · Viewed 8.2k times · Source

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);

Answer

The Muffin Man picture The Muffin Man · May 7, 2017
  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