How to add OAuth2(google auth, facebook auth) to *rest api or graphql in DotNet?

Viewed 18

how to add Oauth2 to rest api or graphql in dotnet? *not MVC.

builder.Services.AddAuthentication(opt =>
{
    opt.DefaultAuthenticateScheme =JwtBearerDefaults.AuthenticationScheme;
    opt.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddGoogle(opt =>
{
    opt.ClientId = builder.Configuration["Authentication:Google:ClientId"];
    opt.ClientSecret = builder.Configuration["Authentication:Google:ClientSecret"];
})

is this only for mvc?

and I don't understand what ProviderKey in aspnetuserlogins table mean....

please answer me how to add oauth2 in dotent rest api or graphql.

0 Answers
Related