I've created an application with asp.net mvc api with users, following this tutorial. And everything works great like that. local users and facebook login works fine.
But now I'm trying to use the FacebookClient and get the user info and friends. But it asks me for the token, but is not the same token that is stored on my session or cookie.
In api controller Account, in GetExternalLogin action I have this code:
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);
}
Here I can find the claims. But not how to use this
My question is how can I store the facebook token on my api after the login?