Closed WayneMRoseberry closed 5 months ago
This article is about adding authentication to a web API app, not a web app. Did you start with a web API, either minimal API or controller-based, that didn't have authentication already configured for it?
Controller based web API.
I had JWT based authentication in place, but was creating the token without a password. It was letting any user with a token on. I was following the article to get a user management system in place. So I guess it would be accurate to say authentication was only partially set up.
The article instructions written do not mention nor configure an email provider. The framework requires an email provider for the application to execute, or at least the configuration set to not use one.
Sent from my Verizon, Samsung Galaxy smartphone Get Outlook for Androidhttps://aka.ms/AAb9ysg
From: Tom Dykstra @.> Sent: Sunday, November 26, 2023 5:13:41 PM To: dotnet/AspNetCore.Docs @.> Cc: WayneMRoseberry @.>; Author @.> Subject: Re: [dotnet/AspNetCore.Docs] Following instructions as written yields error that IEmailSender has not been registered (Issue #31101)
This article is about adding authentication to a web API app, not a web app. Did you start with a web API, either minimal API or controller-based, that didn't have authentication already configured for it?
— Reply to this email directly, view it on GitHubhttps://github.com/dotnet/AspNetCore.Docs/issues/31101#issuecomment-1826984585, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACQTCDDXTV4IYIFR55L3LA3YGPSMLAVCNFSM6AAAAAA7VOHXYWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRWHE4DINJYGU. You are receiving this because you authored the thread.Message ID: @.***>
If you create a new web API project with the project template, it doesn't require email account confirmation. To add email capability to the project you have, see https://learn.microsoft.com/en-us/aspnet/core/security/authentication/accconfirm
The article does not instruct the user how to create their web API. It does not say "Start with this template..."
That said, I did use the ASP .NET Core Web API template which comes with Visual Studio, the one that creates the Weather application. Doing that the instructions in this article still did not work.
From: Tom Dykstra @.> Sent: Monday, November 27, 2023 2:22 PM To: dotnet/AspNetCore.Docs @.> Cc: WayneMRoseberry @.>; Author @.> Subject: Re: [dotnet/AspNetCore.Docs] Following instructions as written yields error that IEmailSender has not been registered (Issue #31101)
If you create a new web API project with the project template, it doesn't require email account confirmation. To add email capability to the project you have, see https://learn.microsoft.com/en-us/aspnet/core/security/authentication/accconfirm
— Reply to this email directly, view it on GitHubhttps://github.com/dotnet/AspNetCore.Docs/issues/31101#issuecomment-1828721076, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACQTCDG6YJ5GBPAQUUMFIQDYGUHDHAVCNFSM6AAAAAA7VOHXYWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRYG4ZDCMBXGY. You are receiving this because you authored the thread.
Are you using the .NET 8.0 SDK (GA release, not a preview or RC)?
Yes
From: Tom Dykstra @.> Sent: Monday, November 27, 2023 2:56 PM To: dotnet/AspNetCore.Docs @.> Cc: WayneMRoseberry @.>; Author @.> Subject: Re: [dotnet/AspNetCore.Docs] Following instructions as written yields error that IEmailSender has not been registered (Issue #31101)
Are you using the .NET 8.0 SDK (GA release, not a preview or RC)?
— Reply to this email directly, view it on GitHubhttps://github.com/dotnet/AspNetCore.Docs/issues/31101#issuecomment-1828764762, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACQTCDB25NOIYYWMEJL4HUTYGULB5AVCNFSM6AAAAAA7VOHXYWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRYG43DINZWGI. You are receiving this because you authored the thread.Message ID: @.***>
What template options did you specify? Where does it error and what is the message when you start with the template?
I am going to need to start over again, because I built this project quite a while back.
I thought (?) I reported the error in the original bug report, but I have it here...
Exception thrown: 'System.InvalidOperationException' in Microsoft.Extensions.DependencyInjection.Abstractions.dll An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.Extensions.DependencyInjection.Abstractions.dll No service for type 'Microsoft.AspNetCore.Identity.IEmailSender`1[Microsoft.AspNetCore.Identity.IdentityUser]' has been registered.
This is the error I get when I try to launch the Web API after following the instructions in the article.
I am not 100% certain on remembering the details, but I believe this happens after the call to "app.MapIdentityApi
From: Tom Dykstra @.> Sent: Monday, November 27, 2023 3:16 PM To: dotnet/AspNetCore.Docs @.> Cc: WayneMRoseberry @.>; Author @.> Subject: Re: [dotnet/AspNetCore.Docs] Following instructions as written yields error that IEmailSender has not been registered (Issue #31101)
What template options did you specify? Where does it error and what is the message when you start with the template?
— Reply to this email directly, view it on GitHubhttps://github.com/dotnet/AspNetCore.Docs/issues/31101#issuecomment-1828786761, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACQTCDDMPB5FQJLCTTS2SPLYGUNLTAVCNFSM6AAAAAA7VOHXYWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRYG44DMNZWGE. You are receiving this because you authored the thread.Message ID: @.***>
I had this exact same issue and looked at the angular example (https://github.com/dotnet/AspNetCore.Docs.Samples/blob/main/samples/ngIdentity/ngIdentity.Server/Program.cs).
I believe the issue is being caused because the documentation omits the additional .AddApiEndPoints() call.
When I changed this section from the documentation:
builder.Services.AddIdentityApiEndpoints
to this:
builder.Services.AddIdentityApiEndpoints
it fixed the error.
Nice, so there was actually something to address in the documentation. I feel good about mentioning it now.
From: dli9431 @.> Sent: Friday, December 08, 2023 2:44 AM To: dotnet/AspNetCore.Docs @.> Cc: WayneMRoseberry @.>; Author @.> Subject: Re: [dotnet/AspNetCore.Docs] Following instructions as written yields error that IEmailSender has not been registered (Issue #31101)
I had this exact same issue and looked at the angular example (https://github.com/dotnet/AspNetCore.Docs.Samples/blob/main/samples/ngIdentity/ngIdentity.Server/Program.cs).
I believe the issue is being caused because the documentation omits the additional .AddApiEndPoints() call.
When I changed this section from the documentation: builder.Services.AddIdentityApiEndpoints() .AddEntityFrameworkStores();
to this: builder.Services.AddIdentityApiEndpoints() .AddEntityFrameworkStores().AddApiEndpoints();
it fixed the error.
- Reply to this email directly, view it on GitHubhttps://github.com/dotnet/AspNetCore.Docs/issues/31101#issuecomment-1846944461, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACQTCDAATFUXDBM6K3RBJVTYILVPXAVCNFSM6AAAAAA7VOHXYWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBWHE2DINBWGE. You are receiving this because you authored the thread.Message ID: @.**@.>>
Hello! Thanks for contacting us. This sounds like a general question about using ASP.NET Core. While we try to look at and respond to all issues, for questions like this we recommend posting to a community support group like Stack Overflow with the asp.net-core
tag.
Potential bugs in the ASP.NET Core framework and product feedback can be reported at dotnet/aspnetcore issues (include full repro steps and cross-link to a repro project in GH when appropriate). For Visual Studio, use the Report a Problem gesture or Suggest a Feature gesture within VS, which open internal issues for the VS team. For Visual Studio Code, you can open an issue at microsoft/vscode issues.
Description
Follow instructions as described in the article.
Compile and run web app.
Result: following error message:
My expectation is that if someone follows the instructions as specified in the article, they will have a functioning web app.
Page URL
https://learn.microsoft.com/en-us/aspnet/core/security/authentication/identity-api-authorization?view=aspnetcore-8.0
Content source URL
https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/security/authentication/identity-api-authorization.md
Document ID
137d4b94-7b26-3911-b22d-42c754a95fc1
Article author
JeremyLikness
Associated WorkItem - 186386