如何使用auth0自定义api发出用户名密码请求

如何使用auth0自定义api发出用户名密码请求

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

问题描述

限时删除!!

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

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 Authorization Settings部分
  4. Default Audience是您的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发出用户名密码请求,并收到错误“不支持的授予类型:密码"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 16:56