【发布时间】:2015-09-11 06:52:20
【问题描述】:
我已经使用 asp.net mvc api 与用户创建了一个应用程序,遵循this tutorial。一切都很好。本地用户和 facebook 登录工作正常。
但现在我正在尝试使用 FacebookClient 并获取用户信息和朋友。 但它要求我提供令牌,但与我的会话或 cookie 中存储的令牌不同。
在 api 控制器帐户中,在 GetExternalLogin 操作中,我有以下代码:
if (hasRegistered)
{
Authentication.SignOut(DefaultAuthenticationTypes.ExternalCookie);
ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(UserManager,
OAuthDefaults.AuthenticationType);
ClaimsIdentity cookieIdentity = await user.GenerateUserIdentityAsync(UserManager,
CookieAuthenticationDefaults.AuthenticationType);
AuthenticationProperties properties = ApplicationOAuthProvider.CreateProperties(user.UserName);
Authentication.SignIn(properties, oAuthIdentity, cookieIdentity);
}
else
{
IEnumerable<Claim> claims = externalLogin.GetClaims();
ClaimsIdentity identity = new ClaimsIdentity(claims, OAuthDefaults.AuthenticationType);
Authentication.SignIn(identity);
}
在这里我可以找到声明。但不是如何使用这个
我的问题是登录后如何将 facebook 令牌存储在我的 api 上?
【问题讨论】:
-
自从您发布这个问题很长时间以来,您是否找到了如何在数据库中保存用户/登录/声明。如果用户已经注册,如何处理。
标签: asp.net asp.net-mvc facebook