Answered by:
Setup Google Authentication

Question
-
User722039657 posted
Hi,
I am using .Net Core 3.1 MVC. I am trying to integrate Google Authentication and the application is not hosted anywhere. I am using IIS Express only and the home page URL is "https://localhost:44312".
For external authentication, I have referred documentation "https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/google-logins?view=aspnetcore-3.1".
Could anyone explain how do I register my web in Google? how do I register the callback URL "https://localhost:44312/signin-google" in Google? Where will I get the Client ID and Client Secret? Could you please explain with screenshots?
Because I couldn't get "Navigate to Integrating Google Sign-In into your web app and select Configure a project". I have sign-in google and accessed the URL - https://developers.google.com/identity/sign-in/web/sign-in, but couldn't find the button "Configure a Project". Could you please guide me?
I have tried the below steps -
- https://developers.google.com/identity/sign-in/web/sign-in
- Go to the Credentials page.
- Created a project and got the project ID (no other options available in this popup)
- From the app library, i have selected Google+ API
- API key generated
- Then clicked the submit consent button
- But I couldn't submit the request
"Google+ API" this option with i selected correct or not? I am totally new to this area, so please guide me from the begining.
Thanks in Advance
Saturday, July 25, 2020 6:56 PM
Answers
-
User711641945 posted
Hi Senthil S R,
Here are the steps about how to use Google Authentication in asp,net core 3.1 mvc:
1.Firstly,Create a mvc project with Identity:
2.Be sure you have Installed Microsoft.AspNetCore.Authentication.Google package.
3.Configure the project in Google:
1>Be sure you have created a new project in this page.
2>Then in the
Credentials
menu, we have to configure a consent screen:3>Choose the External user type:
4>Add the name of the application, and click the Save button at the bottom of the screen:
5>There we can click the
create credentials
link menu and choose theOAuth client ID
.6>Now, we have to choose the Application Type, Name, and add a redirect URIs(The urls port number should be your application launch url,from your description,it should be 44312) for our application:
7>Once we click the Create button, we will get the ClientID and ClientSecret values:
4.Add the Google service to
Startup.ConfigureServices
:services.AddAuthentication() .AddGoogle(options => { IConfigurationSection googleAuthNSection = Configuration.GetSection("Authentication:Google"); options.ClientId = googleAuthNSection["ClientId"]; options.ClientSecret = googleAuthNSection["ClientSecret"]; });
5.Configure your appSettings.json:
"Authentication": { "Google": { "ClientId": "YourClientId", "ClientSecret": "YourClientSecret" } }
6.Run your application:
Best Regards,
Rena
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, July 27, 2020 6:14 AM
All replies
-
User711641945 posted
Hi Senthil S R,
Here are the steps about how to use Google Authentication in asp,net core 3.1 mvc:
1.Firstly,Create a mvc project with Identity:
2.Be sure you have Installed Microsoft.AspNetCore.Authentication.Google package.
3.Configure the project in Google:
1>Be sure you have created a new project in this page.
2>Then in the
Credentials
menu, we have to configure a consent screen:3>Choose the External user type:
4>Add the name of the application, and click the Save button at the bottom of the screen:
5>There we can click the
create credentials
link menu and choose theOAuth client ID
.6>Now, we have to choose the Application Type, Name, and add a redirect URIs(The urls port number should be your application launch url,from your description,it should be 44312) for our application:
7>Once we click the Create button, we will get the ClientID and ClientSecret values:
4.Add the Google service to
Startup.ConfigureServices
:services.AddAuthentication() .AddGoogle(options => { IConfigurationSection googleAuthNSection = Configuration.GetSection("Authentication:Google"); options.ClientId = googleAuthNSection["ClientId"]; options.ClientSecret = googleAuthNSection["ClientSecret"]; });
5.Configure your appSettings.json:
"Authentication": { "Google": { "ClientId": "YourClientId", "ClientSecret": "YourClientSecret" } }
6.Run your application:
Best Regards,
Rena
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, July 27, 2020 6:14 AM -
User-2054057000 posted
Please refer -
How to integrate Google login feature in ASP.NET Core Identity
Monday, July 27, 2020 12:05 PM