NotSupportedException No IUserTwoFactorTokenProvider <TUser> named 'Default' is registered

While modifying .NET Core's Identity files, I stumbled upon this error: NotSupportedException: No IUserTwoFactorTokenProvider<TUser> named 'Default' is registered.

The Microsoft.AspNetCore.Identity.UserManager<TUser>.GenerateUserTokenAsync function couldn't generate a token because no provider was available upon registering a new user. This error has an easy fix though!

If you're like me, you changed AddDefaultIdentity in the Startup.cs file to AddIdentity. I wanted to implement my own user that inherited from the base user. By doing this I lost the default token providers. The fix was to add them back with AddDefaultTokenProviders().

            services.AddIdentity<User, UserRole>()

After that fix, everything worked again!

One Last Thing...

If you have a question or see a mistake, please comment below.

If you found this post helpful, please share it with others. It's the best thanks I can ask for & it gives me momentum to keep writing!

Matt Ferderer
Software Developer focused on making great user experiences. I enjoy learning, sharing & helping others make amazing things.
Let's Connect