访问客户端MVC中的声明(基于令牌的身份验证)

时间:2017-06-07 13:24:21

标签: asp.net-web-api model-view-controller

我在WebApi上有基于令牌的身份验证。具有声明的令牌被发送给MVC客户端。索赔在WebApi中以这样的方式注册

file>export

我检查了索赔并且他们在网络Api中注册,但是当MVC请求令牌时,索赔丢失了。 这发生在clinet MVC app:

 public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
    {

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

        var identity = new ClaimsIdentity(context.Options.AuthenticationType);
        identity.AddClaim(new Claim("userName", context.UserName));
        identity.AddClaim(new Claim("role", "user"));

        context.Validated(identity);
    }

相同的代码在WebApi(服务器)中返回正确的声明 我想我做错了什么

0 个答案:

没有答案
相关问题