EmailTokenProvider generates a very short-lived token and looks like 6 digits. This token is intended for 2FA and is valid only for a short period of time (something like 10-15 minutes, does not know the actual value).
The best thing you can do is use the DataProtectorTokenProvider provided by Identity, and it's a little complicated because it is not easy to tear it from the hands of OWIN.
The way I get around this is to assign a static variable in my Start.Auth.cs , and then reuse it in the UserManager:
public class AuthConfig { public static IDataProtectionProvider DataProtectionProvider { get; set; } public void Configuration(IAppBuilder app) { ConfigureAuth(app); } public void ConfigureAuth(IAppBuilder app) { DataProtectionProvider = app.GetDataProtectionProvider();
And then re-assign it in the UserManager constructor:
var dataProtectorProvider = AuthConfig.DataProtectionProvider; var dataProtector = dataProtectorProvider.Create("My Asp.Net Identity"); this.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser, Guid>(dataProtector) { TokenLifespan = TimeSpan.FromHours(24), };
This way you get a very long email token, which lasts 24 hours.
I made the same mistake as you, but I had to fix it pretty soon, as users complained.
source share