来自POSTMAN Http Tool的Identity Server 3令牌请求

bob*_*zzo 3 postman identityserver3

使用POSTMAN,我正在努力检索我的Identity Server 3令牌.

错误代码是: 400 Bad Request

以下是详细信息:

POST/identity/connect/token HTTP/1.1

Host:localhost:44358 Content-Type:应用程序; x-www-form-urlencoded

Cache-Control: 无缓存

Postman-Token: 57fc7aef-0006-81b2-8bf8-8d46b77d21d1

username= MYUSER-ID&password= MY-PASSWORD&grant_type= password&client_id= rzrwebguiangulajsclient&client_secret= myclientsecret&redirect_uri= https:// localhost:44331/callback

我用一个简单的Visual Studio 2015 WebApi项目做了类似的事情,其终点是\token.

在此输入图像描述

任何指导/建议表示赞赏......

问候,鲍勃

Sco*_*ady 8

资源所有者OAuth请求所需的最低要求如下(为了便于阅读,添加了换行符):

POST/connect/token

Content-Type: application/x-www-form-urlencoded
Run Code Online (Sandbox Code Playgroud)

身体

username=MYUSER-ID
&password=MY-PASSWORD
&grant_type=password
&client_id=rzrwebguiangulajsclient
&client_secret=myclientsecret
&scope=api
Run Code Online (Sandbox Code Playgroud)

你没有在请求中请求范围.否则,在Identity Server中配置客户端可能会出现问题.

您最好的选择是启用日志记录并查看此请求出错时返回的内容.

更新:另外,请不要使用ROPC授权类型

  • 是的,那是错误所在,您的client_secret是错误的。不要忘记应该在客户端配置中对它进行哈希处理(请参阅Identity Server提供的字符串上的.Sha256 helper方法) (2认同)