Custom user claim

Nov 22, 2014 at 8:55 AM

Thank you for this awesome project. It's been a huge help. I have a question though.

When connecting with Facebook as external provider, I get the following response:
"userName": "myUsername",
"access_token": "XX0Aj2IjNEQQMz4F2BlcFRiVuZOXqtsfU6KBYWcPHQO4fzzjNg_RV88nokB65jUThfMKKVS64qu7VIInKW2asthYGB_ng9colx6rl101X_3zYG9PbuCZDBCqf2I5CYpoRnjFhoWFrwrNbygjPhLQEcY5CIsEImWioW6dsDi-UwryldM45JrikEcKI7G3aJNiHR7t-CL6hKL5-jY6ValJvEyO6FfpqOBgPDHyR6eP7YJow52wrgrf8JAErUhxxxxx",
"token_type": "bearer",
"expires_in": "86400",
"issued": "22-11-2014 08:19:25 +00:00",
"expires": "23-11-2014 08:19:25 +00:00"
I want to add a user_id and maybe a firstname and lastname instead of the userName which I am not really using, to the response; where can I add that?


Nov 22, 2014 at 9:09 AM
Nevermind. I've found a helper method from another project, that returned that.
Nov 22, 2014 at 3:23 PM
madebysoren wrote:
Nevermind. I've found a helper method from another project, that returned that.
Well. The question still stands. It did not fix my issue.

When using User.Identity.GetUserId() in my AccountController it returns null. Any idea what I might be missing?
Nov 23, 2014 at 6:54 PM
Check out this helpful article in using fb authentication in the mvc framework: Also, take a look at the sample mvc application available for download at and follow the instructions for setting up the fb authentication and you should be good to go. Hopefully this will get you going.
Nov 24, 2014 at 8:13 AM
Thanks Dave.

I am using your library for Web API only using these tutorials:

I now got it working by consistently using the ClaimsIdentityFactory like this:
public static async Task<ClaimsIdentity> GenerateClaimsIdentity(UserManager<ApplicationUser> userManager, ApplicationUser user)
    var factory = new ClaimsIdentityFactory<ApplicationUser>();
    return await factory.CreateAsync(userManager, user, OAuthDefaults.AuthenticationType);
To use User.Identity.GetUserId() you have to have the correct ClaimsType and the ClaimsIdentityFactory makes sure that you use that. Once more, thanks for a great library!