如何将更多参数传递给令牌终结点Web API 2 [英] How to pass some more parameters to token endpoint web api 2
本文介绍了如何将更多参数传递给令牌终结点Web API 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将更多参数传递给令牌端点
i need to pass some more parameters to token endpoint as
grant_type = password& username = Alice& password = password123& peop1 = value& Prop2 = value
grant_type=password&username=Alice&password=password123&peop1=value&Prop2=value
获取令牌
我如何传递这些密码,以及在哪里可以在服务器上获取它们
How can i pass these and where i can get them on the server
推荐答案
OWIN解决方案,但您可以理解.
Solution for OWIN but you can catch the idea.
通过参数:
grant_type=password&username=Alice&password=password123&peop1=value&Prop2=value
在授权服务器提供商中获取它们:
Get them in your authorization server provider:
public class YourAuthorizationServerProvider : OAuthAuthorizationServerProvider
{
...
public override Task ValidateTokenRequest(OAuthValidateTokenRequestContext context)
{
context.Request.Body.Position = 0;
var reader = new StreamReader(context.Request.Body);
var body = reader.ReadToEnd(); <-- you got them all!
return base.ValidateTokenRequest(context);
}
}
不要忘记在配置中传递您的授权服务器提供商:
Don't forget to pass your authorization server provider in configuration:
...
var options = new OAuthAuthorizationServerOptions
{
Provider = new YourAuthorizationServerProvider()
};
app.UseOAuthAuthorizationServer(options);
...
这篇关于如何将更多参数传递给令牌终结点Web API 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文