我有自己的OAuthAuthorizationServerProvider,但看起来没有地方可以在生成后看到生成的承载令牌。
有没有办法在返回之前获取待返回的令牌? (黑客与否)
这是我的设置:
OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions()
{
AllowInsecureHttp = true,
TokenEndpointPath = new PathString("/token"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
Provider = new SimpleAuthorizationServerProvider()
};
// Token Generation
app.UseOAuthAuthorizationServer(OAuthServerOptions);
app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
答案 0 :(得分:1)
反编译后,从http://katanaproject.codeplex.com/获取OAuth源,并将我的NuGet包升级到最新的Owin实现,我现在可以在SimpleAuthorizationServerProvider中覆盖一个新方法。
public override Task TokenEndpointResponse(OAuthTokenEndpointResponseContext context)
{
string token = context.AccessToken;
return base.TokenEndpointResponse(context);
}
以上将返回ResponseContext,其中包含我需要的所有内容:enctypted token,user identity,claim ...
从NuGet包3开始,这是IOAuthAuthorizationServerProvider接口中的一种新方法(我相信)