2

I would like to use multiple sign-in capabilities for my webapi. I now have a working JWT option for registering / login-in using email / password. Now i would also like to add Google Authentication but am lost how to combine the two.

code for JWT in Startup.CS / ConfigureServices;

// configure jwt authentication
var key = Encoding.ASCII.GetBytes(appSettings.Secret);

services.AddAuthentication(x =>
{
    x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
    x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(x =>
{
    x.RequireHttpsMetadata = false;
    x.SaveToken = true;
    x.TokenValidationParameters = new TokenValidationParameters
    {
        ValidateIssuerSigningKey = true,
        IssuerSigningKey = new SymmetricSecurityKey(key),
        ValidateIssuer = false,
        ValidateAudience = false
    };
})

How would i add the Google authentication here so i can use both?

phicon
  • 3,549
  • 5
  • 32
  • 62
  • 2
    Google auth is not appropriate for web apis, it's designed for interactive browser apps. You'd need an intermediary auth server to exchange Google auth for a JWT. – Tratcher Jan 25 '18 at 14:55
  • @phicon Please see my answer to my question here: https://stackoverflow.com/questions/48727900/google-jwt-authentication-with-aspnet-core-2-0/48768183#48768183 – Mikeyg36 Feb 13 '18 at 13:42

0 Answers0