Now I know there are lots of post about this already but my case is different. So please bear with me.
When I create a WebApi on .Net Framework and choose Individual User accounts, it already scaffolds me a working code for external authentication.
There is AccountController, Startup.auth.cs and other files that has code for External authentication
Now i know things have changed for .net core. But net.core web api on individual user accounts provide nothing similar to it.
When I try to do the same with WebApi on .net Core, it provides me only one option to choose some Azure application.
In the picture below, with WebApi on .net core, that dropdown pointed by blue only provides one option which is Azure AD b2c application. No Account controller is scaffolded and no other configuration files for external authentication as well.
I have tried these links:
https://learn.microsoft.com/en-us/aspnet/web-api/overview/security/external-authentication-services
https://learn.microsoft.com/en-us/aspnet/core/security/authentication/social/
But first link is for .net framework that doesnot help me. The second only works for Web application on asp.net core but NOT WebApi
I need external authentication in web api because I want all my users from Web or mobile to be authenticated by Google or facebook.
Anybody please point me in right direction. Am I missing something here. Are there any documents that can help me with this?
2
Answers
When selecting the “Individual User Accounts” you want to select “Store user accounts in-app”.
When creating the app this way, the scaffolding will create the AccountController.
After you created your project this way you can head over to Startup.cs
In the ConfigureServices Method you have to add (for google):
For more info check out: https://learn.microsoft.com/en-us/aspnet/core/security/authentication/social/
You can use JSON Web Tokens, or JWT.
Here is an article to guide to the right path: https://auth0.com/blog/securing-asp-dot-net-core-2-applications-with-jwts/