【发布时间】:2016-09-23 12:58:54
【问题描述】:
我需要在GrantResourceOwnerCredentials 方法中获取HttpContext.Session。但是,当我尝试访问 Httpcontext.Session 时,我得到了 null。
下面是我的代码:
public void ConfigureAuth(IAppBuilder app)
{
PublicClientId = "self";
OAuthOptions = new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/Token"),
Provider = new ApplicationOAuthProvider(
PublicClientId,
DependencyResolver.Current.GetService<ApplicationUserManager>(),
HttpContext.Current),
//AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(3),
// In production mode set AllowInsecureHttp = false
AllowInsecureHttp = true,
RefreshTokenProvider = new RefreshTokenProvider(
DependencyResolver.Current.GetService<ApplicationDbContext>())
};
// Enable the application to use bearer tokens to authenticate users
app.UseOAuthBearerTokens(OAuthOptions);
}
我使用 SAML 设置我的 HttpContext 会话值,但我需要再次将 Session 值重新检查到我的 GrantResourceOwnerCredentials 方法中,但是这里的会话始终为空。
【问题讨论】:
标签: session oauth-2.0 asp.net-web-api2 saml-2.0 httpcontext