ASP.NET Web API与Owin OAuth:调用与用户相关的Web API(非第三方登录)
授权完成添加属性
ClaimsIdentity oAuthIdentity = await CreateAsync(user/*userManager*/, OAuthDefaults.AuthenticationType, result); //oAuthIdentity.AddClaim(new Claim("proid", names[0])); //ClaimsIdentity cookiesIdentity = await user.GenerateUserIdentityAsync(userManager, // CookieAuthenticationDefaults.AuthenticationType); AuthenticationProperties properties = CreateProperties(user.Id); AuthenticationTicket ticket = new AuthenticationTicket(oAuthIdentity, properties); context.Validated(ticket);
/// <summary> /// 创建属性 /// </summary> /// <param name="userid"></param> /// <returns></returns> public static AuthenticationProperties CreateProperties(string userid) { IDictionary<string, string> data = new Dictionary<string, string> { { "userid", userid }, {"version","2.2"} }; return new AuthenticationProperties(data); }
返回的:
未完成先占位