我已經創建了一個應用程序與用戶的asp.net mvc api,跟隨this tutorial。一切都很好。本地用戶和Facebook登錄工作正常。asp.net mvc API獲取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);
}
在這裏我能找到的索賠。但不是如何使用這個
我的問題是如何在登錄後在我的api上存儲Facebook令牌?
由於很長一段時間你發佈這些問題,你有沒有找到如何將用戶/登錄/索賠保存在數據庫。如果用戶已經註冊,該如何處理。 –