41

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
  • 60,696
  • 40
  • 206
  • 339
Piotrek
  • 10,919
  • 18
  • 73
  • 136

1 Answers1

56

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
  • 39,509
  • 7
  • 121
  • 131
  • 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
  • 4
    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