I am trying to integrate google authentication in my ASP.NET Core 2.0 web api and I cannot figure out how to get it to work.
I have this code in my Startup.cs
I just published a NuGet package to handle validation of Google OpenID Connect tokens.
The package relies on Microsoft's JWT validation and authentication handler from Microsoft.AspNetCore.Authentication.JwtBearer, with some added validation around hosted domains.
It contains a single public extension method, UseGoogle
, on JwtBearerOptions
that lets you configure the handler to validate Google OpenID Connect tokens, without other dependencies:
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(jwt => jwt.UseGoogle(
clientId: "",
hostedDomain: ""));
If you want to take a look at the source, you can find it here.