相关疑难解决方法(0)

OAuth2 WebApi令牌过期

我试图动态设置令牌到期时间,但它似乎只是默认为20分钟.

这是我的ConfigureAuth:

public void ConfigureAuth(IAppBuilder app)
{

        OAuthOptions = new OAuthAuthorizationServerOptions
        {
            TokenEndpointPath = new PathString("/Token"),
            Provider = new ApplicationOAuthProvider(""),
            // In production mode set AllowInsecureHttp = false
            AllowInsecureHttp = true
        };

        // Enable the application to use bearer tokens to authenticate users
        app.UseOAuthBearerTokens(OAuthOptions);

}
Run Code Online (Sandbox Code Playgroud)

这是我的GrantResourceOwnerCredentials方法:

    public override Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
    {

        context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });

        var hasValidLogin = (new login().authenticate(context.UserName, context.Password, "") == "valid");

        if (hasValidLogin == false)
        {
            context.SetError("invalid_grant", "The user name or password is incorrect.");
            return …
Run Code Online (Sandbox Code Playgroud)

asp.net oauth oauth-2.0 asp.net-web-api owin

14
推荐指数
2
解决办法
2万
查看次数

标签 统计

asp.net ×1

asp.net-web-api ×1

oauth ×1

oauth-2.0 ×1

owin ×1