我正在尝试使用ASP.NET Web API和基于OAuth令牌的身份验证集成来构建应用程序。
OAuth中间件实现
我曾经重写OAuthAuthorizationServerProvider
基类,这里是我的代码:
public override Task
ValidateclientAuthentication(OAuthValidateclientAuthenticationContext context)
public override Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
客户: 我使用Postman进行API交互,在这里我使用以下参数来获取有效的身份验证令牌:
"headers": {
"content-type": "application/x-www-form-urlencoded",}
"data":{
"grant_type": "password","username": "######","password": "######","client_id": "#######"
}
它运行良好并获得了有效的身份验证令牌。
我想在标头部分而不是请求正文中传递grant_type
"headers": {
"content-type": "application/x-www-form-urlencoded","grant_type": "password",}
"data":{
"username": "######","client_id": "#######"
}
但出现如下错误:
{
"error": "unsupported_grant_type"
}
我们可以传递grant_type
标头部分吗?