Skip to main content
Login Register
Code2night
  • Home
  • Blog Archive
  • Learn
    • Tutorials
    • Videos
  • Interview Q&A
  • Resources
    • Cheatsheets
    • Tech Comparisons
  • Languages
    • Angular Angular js ASP.NET Asp.net Core ASP.NET Core, C# ASP.NET MVC ASP.NET Web Forms C C# C#, ASP.NET Core, Dapper
      C#, ASP.NET Core, Dapper, Entity Framework DotNet General Web Development HTML, CSS HTML/CSS Java JavaScript JavaScript, HTML, CSS JavaScript, Node.js Node.js
      Python Python 3.11, Pandas, SQL Python 3.11, SQL Python 3.11, SQLAlchemy Python 3.11, SQLAlchemy, SQL Python 3.11, SQLite React Security SQL Server TypeScript
  • Post Blog
  • Tools
    • Beautifiers
      JSON Beautifier HTML Beautifier XML Beautifier CSS Beautifier JS Beautifier SQL Formatter
      Dev Utilities
      JWT Decoder Regex Tester Diff Checker Cron Explainer String Escape Hash Generator Password Generator
      Converters
      Base64 Encode/Decode URL Encoder/Decoder JSON to CSV CSV to JSON JSON to TypeScript Markdown to HTML Number Base Converter Timestamp Converter Case Converter
      Generators
      UUID / GUID Generator Lorem Ipsum QR Code Generator Meta Tag Generator
      Image Tools
      Image Converter Image Resizer Image Compressor Image to Base64 PNG to ICO Background Remover Color Picker
      Text & Content
      Word Counter PDF Editor
      SEO & Web
      SEO Analyzer URL Checker World Clock
  1. Home
  2. Blog
  3. ASP.NET Core
  4. How to Integrate Google Sign in Asp.net Core 8.0

How to Integrate Google Sign in Asp.net Core 8.0

Date- May 05,2024 Updated Jan 2026 7948 Free Download Pay & Download
Google Sign In Google Login


Google Authentication


To integrate Google SignIn into your Asp.Net Core 8.0 project, we'll start by logging into the Google Developer Console. When you log in, you'll see the following windowHow to Integrate Google Sign in Aspnet Core 80


After this, you'll need to click on 'Enable APIs and Services,' as shown in the screenshot. To obtain API keys, you'll also need to create a new project on the Google Developer Console. You can see this in the next image



How to Integrate Google Sign in Aspnet Core 80 2


Click on the dropdown on top, as showed in the image

How to Integrate Google Sign in Aspnet Core 80 3


Here you will find the projects which are already created. if you want to add new project than click on new project button

How to Integrate Google Sign in Aspnet Core 80 4


For adding the new project you have to provide the Name of project and then you can click on create


How to Integrate Google Sign in Aspnet Core 80 5

After filling the project name click on create

How to Integrate Google Sign in Aspnet Core 80 6

Now you have to click on Api & services and there we will enable Google + api.

How to Integrate Google Sign in Aspnet Core 80 7

You can search the api's provided by google. We have to find out Google+ Api and click on that.

How to Integrate Google Sign in Aspnet Core 80 8

Now it will ask you to click on Enable , then this api will be added to your account and project.

How to Integrate Google Sign in Aspnet Core 80 9


After we have enabled the Api you have to go to Oauth Consent Screen menu as you can see in next image. You have to select External in the screen and click on create


How to Integrate Google Sign in Aspnet Core 80 10


How to Integrate Google Sign in Aspnet Core 80 11

Now you will get this screen, you have to click on save and continue

How to Integrate Google Sign in Aspnet Core 80 12


How to Integrate Google Sign in Aspnet Core 80 13

Now it will move to next step a, you can again click on Save and continue

How to Integrate Google Sign in Aspnet Core 80 14


How to Integrate Google Sign in Aspnet Core 80 15


How to Integrate Google Sign in Aspnet Core 80 16


Now we have to create new credential for api, you have to click on Create Credentials from top as showed n thisHow to Integrate Google Sign in Aspnet Core 80 17

Now we have to click on Oauth Client id as showed in the image

How to Integrate Google Sign in Aspnet Core 80 18Now this screen will appear, here we have to set the callback you, this must be the url from project on which you will get callback after google loginHow to Integrate Google Sign in Aspnet Core 80 19

Now, you will see this window, you can copy the credential, which we will use in the project.

How to Integrate Google Sign in Aspnet Core 80 20

After we have got client id and client secret, we will go to our Asp.Net Core 8.0 project and add one package RestSharp as you see in the image, you have to use latest version 110.2.0How to Integrate Google Sign in Aspnet Core 80 21

  public ActionResult GoogleLoginCallback(string code)
 {
     if (code != null)
     {
         var client = new RestClient("https://www.googleapis.com/oauth2/v4/token");
         var request = new RestRequest() { Method=Method.Post};
         ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
         request.AddParameter("grant_type", "authorization_code");
         request.AddParameter("code", code);
         request.AddParameter("redirect_uri", "https://localhost:44328/Home/GoogleLoginCallback");

         request.AddParameter("client_id", "Enter your clientId");
         request.AddParameter("client_secret", "Enter your client secret");

         RestResponse response = client.Execute(request);
         var content = response.Content;
         var res = (JObject)JsonConvert.DeserializeObject(content);
         var client2 = new RestClient("https://www.googleapis.com/oauth2/v1/userinfo");
         client2.AddDefaultHeader("Authorization", "Bearer " + res["access_token"]);

         request = new RestRequest() { Method = Method.Get };


         var response2 = client2.Execute(request);

         var content2 = response2.Content;

         var user = (JObject)JsonConvert.DeserializeObject(content2);
         return RedirectToAction("Index", "Home");

     }
     else
     {
         ViewBag.ReturnData = "";
     }

     return View();
 }

You have to use this code on your controller action which was mentioned in the redirect uri section on Google Developer console. And also redirect uri must be same on Action and on Google Developer console.

How to Integrate Google Sign in Aspnet Core 80 22
<a class="btn btn-default" href="https://accounts.google.com/o/oauth2/auth?client_id=127778789128-m6g5im9ofzcclmi4ujqb16u8840lb2pj.apps.googleusercontent.com&redirect_uri=https://localhost:44328/Home/GoogleLoginCallback&scope=https://www.googleapis.com/auth/userinfo.profile&response_type=code&state=asdafwswdwefwsdg">Goggle Log in</a>

Add this button on you view, you have to modify the redirecturl and clientid on the anchor button which we have taken, as showed in the image

How to Integrate Google Sign in Aspnet Core 80 23

Replace these client id and redirect url, with your created credentials

How to Integrate Google Sign in Aspnet Core 80 24

Now you can run the project and see you will see Google Login button , now on clicking that it will go to google sign in screenHow to Integrate Google Sign in Aspnet Core 80 25

This is what you will get after click on button, you can Add new google account or use existing one. On the selection, it will go to you callback method.

How to Integrate Google Sign in Aspnet Core 80 26

You will get the logged in user details like this in the google callback method.

How to Integrate Google Sign in Aspnet Core 80 27

You can get the complete code by download attachment. Let us know if you face any issue.

This is how we can integrate google sign or google login in Asp.Net Core 8.0

In conclusion, integrating Google SignIn into your Asp.Net Core 8.0 project provides a seamless and secure authentication option for users. By following the steps outlined in this guide, you can easily enable Google SignIn by creating a new project on the Google Developer Console, obtaining API keys, and configuring authentication settings in your Asp.Net Core application. Leveraging Google's authentication service not only simplifies the login process for users but also enhances the overall security of your application. Embracing this integration empowers developers to deliver a more user-friendly and robust authentication experience in their Asp.Net Core 8.0 projects.

S
Shubham Batra
Programming author at Code2Night — sharing tutorials on ASP.NET, C#, and more.
View all posts →

Related Articles

Integrating Google Sign in Asp.net MVC
Jan 22, 2022
Linkedin Sign In using LinkedinLogin Nuget package in Asp-Net MVC
Apr 14, 2023
Google Sign In using GoogleAuthentication Nuget package in Asp.Net MVC
Mar 12, 2022
How to implement Paypal in Asp.Net Core 8.0
Nov 24, 2023
Previous in ASP.NET Core
How to fix Xml Injection vulnerability in asp.net (CWE-91)
Next in ASP.NET Core
Understanding Middleware in ASP.NET Core: A Comprehensive Guide
Buy me a pizza

Comments

🔥 Trending This Month

  • 1
    HTTP Error 500.32 Failed to load ASP NET Core runtime 6,933 views
  • 2
    Error-An error occurred while processing your request in .… 11,269 views
  • 3
    Comprehensive Guide to Error Handling in Express.js 234 views
  • 4
    ConfigurationBuilder does not contain a definition for Set… 19,458 views
  • 5
    Mastering JavaScript Error Handling with Try, Catch, and F… 160 views
  • 6
    Mastering Unconditional Statements in C: A Complete Guide … 21,491 views
  • 7
    Unable to connect to any of the specified MySQL hosts 6,225 views

On this page

🎯

Interview Prep

Ace your ASP.NET Core interview with curated Q&As for all levels.

View ASP.NET Core Interview Q&As

More in ASP.NET Core

  • How to Encrypt and Decrypt Password in Asp.Net 26063 views
  • Exception Handling Asp.Net Core 20794 views
  • HTTP Error 500.31 Failed to load ASP NET Core runtime 20287 views
  • How to implement Paypal in Asp.Net Core 19675 views
  • Task Scheduler in Asp.Net core 17576 views
View all ASP.NET Core posts →

Tags

AspNet C# programming AspNet MVC c programming AspNet Core C software development tutorial MVC memory management Paypal coding coding best practices data structures programming tutorial tutorials object oriented programming Slick Slider StripeNet
Free Download for Youtube Subscribers!

First click on Subscribe Now and then subscribe the channel and come back here.
Then Click on "Verify and Download" button for download link

Subscribe Now | 1770
Download
Support Us....!

Please Subscribe to support us

Thank you for Downloading....!

Please Subscribe to support us

Continue with Downloading
Be a Member
Join Us On Whatsapp
Code2Night

A community platform for sharing programming knowledge, tutorials, and blogs. Learn, write, and grow with developers worldwide.

Panipat, Haryana, India
info@code2night.com
Quick Links
  • Home
  • Blog Archive
  • Tutorials
  • About Us
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Guest Posts
  • SEO Analyzer
Dev Tools
  • JSON Beautifier
  • HTML Beautifier
  • CSS Beautifier
  • JS Beautifier
  • SQL Formatter
  • Diff Checker
  • Regex Tester
  • Markdown to HTML
  • Word Counter
More Tools
  • Password Generator
  • QR Code Generator
  • Hash Generator
  • Base64 Encoder
  • JWT Decoder
  • UUID Generator
  • Image Converter
  • PNG to ICO
  • SEO Analyzer
By Language
  • Angular
  • Angular js
  • ASP.NET
  • Asp.net Core
  • ASP.NET Core, C#
  • ASP.NET MVC
  • ASP.NET Web Forms
  • C
  • C#
  • C#, ASP.NET Core, Dapper
  • C#, ASP.NET Core, Dapper, Entity Framework
  • DotNet
  • General Web Development
  • HTML, CSS
  • HTML/CSS
  • Java
  • JavaScript
  • JavaScript, HTML, CSS
  • JavaScript, Node.js
  • Node.js
  • Python
  • Python 3.11, Pandas, SQL
  • Python 3.11, SQL
  • Python 3.11, SQLAlchemy
  • Python 3.11, SQLAlchemy, SQL
  • Python 3.11, SQLite
  • React
  • Security
  • SQL Server
  • TypeScript
© 2026 Code2Night. All Rights Reserved.
Made with for developers  |  Privacy  ·  Terms
Translate Page
We use cookies to improve your experience and analyze site traffic. By clicking Accept, you consent to our use of cookies. Privacy Policy
Accessibility
Text size
High contrast
Grayscale
Dyslexia font
Highlight links
Pause animations
Large cursor