AddIdentityApiEndpoints() is a .net 8 feature. Just upgrade to .net 8. Net 7 support ends in May, so you should be upgrading soon anyway.
Add Identity endpoints in my API
Hey I would like to add the identity endpoints in my API I add this service in program
"builder.Services.AddIdentityApiEndpoints<IdentityUser>()
.AddEntityFrameworkStores<ApplicationDbContext>();"
but "AddIdentityApiEndpoints" is not recognized I use dot net 7, need help
Developer technologies | .NET | Entity Framework Core
Developer technologies | ASP.NET | ASP.NET Core
Microsoft Security | Microsoft Identity Manager
Developer technologies | C#
-
Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
2024-01-21T18:13:01.2866667+00:00
1 additional answer
Sort by: Most helpful
-
Anonymous
2024-01-24T07:03:20.7066667+00:00 Hi @Marnelle M'BENGUET
As Bruce said, the Identity API endpoints (AddIdentityApiEndpoints) is the new feature in .NET 8. You can't use it in .NET 7 application. Refer to the relevant documentation: Identity API endpoints. So, to use the Identity API endpoints, you can refer to the following article to migrate your application to .NET 8.
Migrate from ASP.NET Core 7.0 to 8.0
If you don't want to upgrade the application, and still want to use .NET 7. You can use the Asp.net Core Identity Library for authentication and authorization.
Identity Register code like this:builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true) .AddEntityFrameworkStores<ApplicationDbContext>(); builder.Services.AddRazorPages(); builder.Services.Configure<IdentityOptions>(options => { // Password settings. options.Password.RequireDigit = true; options.Password.RequireLowercase = true; options.Password.RequireNonAlphanumeric = true; options.Password.RequireUppercase = true; options.Password.RequiredLength = 6; options.Password.RequiredUniqueChars = 1; // Lockout settings. options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(5); options.Lockout.MaxFailedAccessAttempts = 5; options.Lockout.AllowedForNewUsers = true; // User settings. options.User.AllowedUserNameCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+"; options.User.RequireUniqueEmail = false; });
Note: The primary package for Identity is Microsoft.AspNetCore.Identity. This package contains the core set of interfaces for ASP.NET Core Identity, and is included by
Microsoft.AspNetCore.Identity.EntityFrameworkCore
.
More detail information, see:
Introduction to Identity on ASP.NET Core
Scaffold Identity in ASP.NET Core projects
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion