Skip to content

Instantly share code, notes, and snippets.

@thomaslevesque
Last active February 27, 2019 16:18
Show Gist options
  • Save thomaslevesque/fe2cb14377e30833484f75ac416134bb to your computer and use it in GitHub Desktop.
Save thomaslevesque/fe2cb14377e30833484f75ac416134bb to your computer and use it in GitHub Desktop.
Google authentication in ASP.NET Core with the built-in provider vs. with OpenId Connect
// Before
services
.AddAuthentication()
.AddGoogle(options =>
{
options.ClientId = configuration["Authentication:Google:ClientId"];
options.ClientSecret = configuration["Authentication:Google:ClientSecret"];
});
// After
services
.AddAuthentication()
.AddOpenIdConnect(
authenticationScheme: "Google",
displayName: "Google",
options =>
{
options.Authority = "https://accounts.google.com/";
options.ClientId = configuration["Authentication:Google:ClientId"];
options.CallbackPath = "/signin-google";
options.SignedOutCallbackPath = "/signout-callback-google";
options.RemoteSignOutPath = "/signout-google";
options.Scope.Add("email");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment