ASP.NET Core Google Authentication Example in MVC Application

This is an example of how to use ASP.NET Core's Google authentication.

The purpose of using this ASP.NET Core's Google authentication example is to show you how to integrate Google external login, and how to set it up in ASP.NET Core.

The application uses ASP.NET Core MVC and integrates with the Google Cloud Service.

We show you how to set up a Google Cloud Service application and how to integrate it into the MVC app. You will need to get your own client ID and client secret from Google in-order to use this application successfully.

When you download the source code from the repository, you will be required to input your Google credentials into the application.

From there, you will be able to view an authentication page using your Google login account.

Software

This is the software that will need to be installed onto your machine.

  • Visual Studio 2019. Version 16.6.4 or above. It will work with the free community version.
  • .NET 3.1.6 SDK. Other SDK's above this may work, but this has not been tried out.

Get The Application Working

These are the steps to get the application working.

  • Fill out the Download the Source Code form. We will send you an email where you can download the source code.
  • Set up a service in Google Cloud Console. The service will generate a client ID and secret that you will need. Read our How to Add Google Authentication to a ASP.NET Core Application article for full details on how to do this.
  • Input the ClientId from the Google Cloud Console service into the line 38 of RoundTheCode.GoogleAuthentication/Startup.cs from the source code.
  • Input the ClientSecret from the Google Cloud Console service into the line 39 of RoundTheCode.GoogleAuthentication/Startup.cs from the source code.

From there:

  • Start the application in Visual Studio, and navigate to https://localhost:8888 in your favourite web browser.
  • Click on the Privacy Policy page, and you should be redirected to Google's login page.
  • Log in with your Google account, and you should be redirected back to the app. It should display all the claims that have been returned from Google.

Watch The Video

If you are unsure on how to get the application working, you can watch our live stream that we did on Google Authentication.

We created a new project in Google Cloud Platform, set up Google authentication in an ASP.NET Core application and watch the Google authentication in action, including the claims that are exposed from Google.

Join our Discord Server

  • Can't get your ASP.NET Core application to work? Ask for help here!
  • Discussions with other ASP.NET Core developers.
  • General chat with the community.
Join