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.

Leave a Comment