I've been following a tutorial on webapi oauth login here;
It all runs smoothly but I am having difficulty with retrieving the token sent back from the external provider (in this test case Google).
So after the user authenticates and confirms the login the "ExternalLogin" end point for the second time on the webapi with the authentication data.
in this method it calls the following to extract all the data to a class
ExternalLoginData externalLogin = ExternalLoginData.FromIdentity(User.Identity as ClaimsIdentity);
Its here that it seems to be falling over. As when it call the FromIdentity method;
public static ExternalLoginData FromIdentity(ClaimsIdentity identity)
{
if (identity == null)
{
return null;
}
Claim providerKeyClaim = identity.FindFirst(ClaimTypes.NameIdentifier);
if (providerKeyClaim == null || String.IsNullOrEmpty(providerKeyClaim.Issuer) || String.IsNullOrEmpty(providerKeyClaim.Value))
{
return null;
}
if (providerKeyClaim.Issuer == ClaimsIdentity.DefaultIssuer)
{
return null;
}
return new ExternalLoginData
{
LoginProvider = providerKeyClaim.Issuer,
ProviderKey = providerKeyClaim.Value,
UserName = identity.FindFirstValue(ClaimTypes.Name),
ExternalAccessToken = identity.FindFirstValue("ExternalAccessToken"),
};
}
the line;
ExternalAccessToken = identity.FindFirstValue("ExternalAccessToken")
is returning as null? I can't see this token being returned in any of the claims?