如何使用auth0自定义api进行用户名密码请求,收到错误"不支持的授予类型:密码"错误

Mon*_*key 13 auth0

我尝试使用auth0邮递员模板使用用户名和密码进行身份验证请求,我得到了一个unsupported grant type: password error.我究竟做错了什么?

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);
Run Code Online (Sandbox Code Playgroud)

The*_*Man 38

  1. 登录Auth0仪表板
  2. 转到帐户设置(位于用户名右上角)
  3. 在常规选项卡上向下滚动到该API Authorization Settings部分
  4. Default Audience 将是您的API标识符(如果您有API)
  5. Default Directory 将是您的连接,如数据库连接名称

在POST到oauth/token的POST中不包括受众(如果您指定了上面的默认值).

一定要喜欢Auth0在同一时间让身份验证变得轻松而痛苦.

请参阅下面的屏幕截图作为参考 在此输入图像描述


小智 5

转到默认应用程序 > 设置 >

在设置底部,点击{显示高级设置}

选择资助类型选项卡

勾选密码,默认不勾选

将请求发布到 *//oauth/token 并且它有效

在此输入图像描述