- Home
- .NET code examples
- ASP.NET Core Google Authentication example in MVC application
ASP.NET Core Google Authentication example in MVC application
This is an example of how to use ASP.NET Core's Google authentication.
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 code example 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
ClientIdfrom the Google Cloud Console service into the line 38 ofRoundTheCode.GoogleAuthentication/Startup.csfrom the source code. - Input the
ClientSecretfrom the Google Cloud Console service into the line 39 ofRoundTheCode.GoogleAuthentication/Startup.csfrom the source code.
From there:
- Start the application in Visual Studio, and navigate to
https://localhost:8888in 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.
Give us your anonymous feedback regarding this page, or any other areas of the website.
Watch .NET tutorials
Subscribe to our YouTube channel
Related code examples
Basic authentication in ASP.NET Core
Purchase a ASP.NET Core Basic authentication example allowing you to add the Authorization header to a HTTP request.