Web API and social sign-in provider authentication (Google) #29187
-
The short versionI'm trying to use Google social authentication in a simple Web API project (roughly The long versionContextI need to integrate Google login in an existing web application. The web application is made with plain old HTML / CSS / JS for the frontend (no React, no Angular, no Vue, no <insert your super fancy 10GB of client-side code web frontend framework here>), and the backend is just an ASP.NET Core Web API (migrated to .NET 5) with controllers (no Web Application with MVC or RazorPages or whatever). I've tried so many approaches that I've lost track of what I tried and how. Lately I decided to restart over my painful experiments with ASP.NET Core and track everything. I started by following this link: https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/social-without-identity?view=aspnetcore-5.0 So the code of my sample is exactly the same as on this documentation I followed, except that the services.AddControllers(); instead of services.AddRazorPages(); And the app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
}); instead of app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
}); The problemAfter I started the application, when I navigate to the Here is the raw exception details:
PrecisionsI've setup the I'm including The frontend is made of plain old HTML / CSS / JS but is actually massive, and I don't own it, so there is no way I migrate it to Angular or whatever other web frontend framework, nor ask my customer to do so. The Web API project is also massive, and I do not want to migrate it to MVC or RazorPages or else. The Google project is correctly configured (again, it works with my custom authentication middleware), and I run the sample without IIS Express to avoid random port and use port 5001 instead, to match the Google project configuration. I do not want to use EntityFramework nor need any database to store info about users, allowed users will just be stored in a simple JSON file, such as: {
"allowed": [
"alice@gmail.com",
"bob@gmail.com"
]
} The questionWhat am I missing ? Having the frontend in plain HTML / CSS / JS is a requirement, and keeping the backend as a Web API project is also a requirement, so please avoid answers like "why don't you use Angular ?" or "why don't you use RazorPages ?". I know this is technically possible because it works with my custom authentication middleware. However, if Thank you for your help. Further precisions
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I got the problem, manually going to |
Beta Was this translation helpful? Give feedback.
I got the problem, manually going to
/signin-google
is completely wrong.