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);
        }

返回的:

 

未完成先占位

posted @ 2015-12-22 11:22  nele  阅读(469)  评论(0编辑  收藏  举报