.net core 2 Google Authentication login loop

I am trying to authenticate using google in .net core 2 and have done what seems to be the very simple set up required for this:

1) Added app.UseAuthentication(); to Configure(..) in startup.cs

2) Added to ConfigureServices(..) startup.cs

services.AddAuthentication(options => { options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = GoogleDefaults.AuthenticationScheme; }) .AddCookie() .AddGoogle(options => { options.ClientId = Configuration["auth:google:clientid"]; options.ClientSecret = Configuration["auth:google:clientsecret"]; });

Added the appropriate values to my appsettings.json for the id and secret that I got from Google Dev.

Added a <strong>web-api</strong> controller with an [Authorize] attribute.

Done the appropriate stuff in google dev to set the Authorised JavaScript origins to http://localhost:50741 (my root) and Authorised redirect URIs to http://localhost:50741/signin-google


Going to the secured controller endpoint results in a redirect to the google webpage where I can choose a google profile, I choose one and it redirects back to http://localhost:50741/signin-google and then immediately back to the google profiles screen creating an infinite loop.

Where have I gone wrong?


It all works fine if I change the [Authorize] attribute to [Authorize(AuthenticationSchemes = CookieAuthenticationDefaults.AuthenticationScheme)]


  • How to obtain the token returned from Azure AD B2C in ASP Core 2.0?
  • Display and delete multiple cookies in Javascript
  • Cookie maxAge always -1
  • Store background-color when hover a table row in jQuery
  • Class 'Google_Client' not found
  • Custom Implementation of IClientStore
  • How to Find UserControls Control value in Jquery Asp.net?
  • How to run downloaded App Router via Service Marketplace
  • Microsoft graph and Azure Ad user authentication
  • Android: Using Cookies in HTTP Post request
  • How to resolve ' error TS2351: Cannot use 'new' with an expression whose type lacks a
  • Enable image upload for CKEditor at asp.net
  • Accessing Telerik RadGrid edit mode from javascript
  • Firebase Function not returning expected environment configuration when served locally
  • call js confirm from code behind
  • How to handle keydown Event in asp.net Textbox?
  • IE6 textBox.focus(); causing “Unexpected call to method or property access”
  • How can I implement PersistedGrantStore on my mongodb database
  • .net core 2 Google Authentication login loop
  • firing ASP.NET Events from javascript
  • Getting a ASP Error: Mailbox unavailable. The server response was: Access denied - Invalid HELO name
  • Is it possible to display more than one item in a cell with a foreach condition?
  • Error The 'ClientId' option must be provided. When building a docker image
  • Token-based database authentication fails with “Login failed for user 'NT AUTHORITY\\ANONYMOU
  • Delphi TStringGrid multi select, determining selected rows
  • Selenium JS add cookie to request
  • Datatables: custom function inside of fnRowCallback
  • using class interface as a parameter in wcf service
  • Set cookie only after file download complete.
  • connecting to web api using c#
  • Google script gmail addon update TextInput value,on change function
  • Clickable Webcontrol, ASP.NET
  • How to retrieve information from antrun back to maven?
  • How can I replace the server in Web Component Tester
  • Is there some graphical way to create my own configuration file on SonarLint?
  • Spring Cloud Microservice Architecture Confusion
  • How can I send an e-mail from a vbs script
  • Is there a mandatory requirement to switch app.yaml?
  • UserPrincipal.Current returns apppool on IIS