36

I found this in my Startup.cs file in ConfigureServices in a default Visual Studio 2015 ASP.NET 5 project:

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

What does it exactly do, and how to use those "default providers"? Does it configure all token-based authentication for me? Where can I read more about it?

Jeroen
  • 56,917
  • 35
  • 193
  • 305
Piotrek
  • 10,309
  • 14
  • 71
  • 127

1 Answers1

52

Despite their name, the token providers have nothing to do with token authentication: they are exclusively used to generate opaque tokens for account operations (like password reset or email change) and two-factor authentication.

There are currently 3 built-in providers:

ASP.NET Core 1.0 doesn't offer native token authentication support (only token validation is supported: you can't produce your own tokens). You can read these SO posts for more information:

Community
  • 1
  • 1
Kévin Chalet
  • 36,739
  • 7
  • 114
  • 128
  • How about using an `IUserTokenProvider` for generating JWT refresh tokens - which can be just opaque tokens. Just wondering if this would be a good fit.. – Darrell Apr 20 '17 at 13:01
  • 3
    Here'a a good post on the topic https://www.stevejgordon.co.uk/asp-net-core-identity-token-providers – cecilphillip Jun 07 '17 at 15:50