相关疑难解决方法(0)

Owin Bearer令牌认证+授权控制器

我正在尝试使用Bearer令牌和owin进行身份验证.

我可以使用授权类型发出令牌passwordGrantResourceOwnerCredentialsAuthorizationServerProvider.cs中重写.

但我无法使用该Authorize属性访问控制器方法.

这是我的代码:

Startup.cs

public class Startup
{
    public static OAuthAuthorizationServerOptions OAuthOptions { get; private set; }

    // normal
    public Startup() : this(false) { }

    // testing
    public Startup(bool isDev)
    {
        // add settings
        Settings.Configure(isDev);

        OAuthOptions = new OAuthAuthorizationServerOptions
        {
            AllowInsecureHttp = true,
            TokenEndpointPath = new PathString("/Token"),
            AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
            Provider = new AuthorizationServerProvider()
        };
    }

    public void Configuration(IAppBuilder app)
    {
        // Configure the db context, user manager and role manager …
Run Code Online (Sandbox Code Playgroud)

c# authentication token owin

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

标签 统计

authentication ×1

c# ×1

owin ×1

token ×1