Asp.NET Identity 2 giving “Invalid Token” error

I encountered this problem and resolved it. There are several possible reasons. 1. URL-Encoding issues (if problem occurring “randomly”) If this happens randomly, you might be running into url-encoding problems. For unknown reasons, the token is not designed for url-safe, which means it might contain invalid characters when being passed through a url (for example, … Read more

No IUserTokenProvider is registered

You have to specify a UserTokenProvider to generate a token. using Microsoft.Owin.Security.DataProtection; using Microsoft.AspNet.Identity.Owin; // … var provider = new DpapiDataProtectionProvider(“SampleAppName”); var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>()); userManager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser>( provider.Create(“SampleTokenName”)); You should also read this article: Adding Two Factor Authentication to an Application Using ASP.NET Identity.

How to extend available properties of User.Identity

Whenever you want to extend the properties of User.Identity with any additional properties like the question above, add these properties to the ApplicationUser class first like so: public class ApplicationUser : IdentityUser { public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager) { // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType var userIdentity = await manager.CreateIdentityAsync(this, … Read more