No IUserTokenProvider is registered No IUserTokenProvider is registered asp.net asp.net

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.


In ASP.NET Core it's nowadays possible to configure a default service in the Startup.cs like this:

services.AddIdentity<ApplicationUser, IdentityRole>()    .AddDefaultTokenProviders();

There is no need to call the DpapiDataProtectionProvideror anything like that. The DefaultTokenProviders() will take care of the call to GenerateEmailConfirmationToken from the UserManager.


In addition to the accepted answer, I'd like to add that this approach will not work in Azure Web-Sites, you'd get CryptographicException instead of a token.

To get it fixed for Azure, implement your own IDataProtector: see this answer

Slightly more detail in blog-post