如何使用 auth0 自定义 api 发出用户名密码请求,出现错误“不支持的授权类型:密码"错误 [英] How to make a username password request with auth0 custom api, getting error "unsupported grant type: password" error

查看:24
本文介绍了如何使用 auth0 自定义 api 发出用户名密码请求,出现错误“不支持的授权类型:密码"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 auth0 邮递员模板使用用户名和密码发出身份验证请求,但我收到了不支持的授权类型:密码错误.我做错了什么?

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

推荐答案

  1. 登录到 Auth0 仪表板
  2. 转到帐户设置(在您的用户名右上方)
  3. 在常规选项卡上向下滚动到 API 授权设置 部分
  4. 默认受众 将是您的 API 标识符(如果您有 API)
  5. Default Directory 将是您的连接,例如数据库连接名称
  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

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

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

必须喜欢 Auth0 如何使身份验证既简单又困难.

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

参考下面的截图作为参考.

Refer below screenshot as a reference.

这篇关于如何使用 auth0 自定义 api 发出用户名密码请求,出现错误“不支持的授权类型:密码"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆