I have a Mobile app which Authenticates against my Web Api, i am issuing user's a JWT token upon successful login, which users can use with all subsequent requests. this is how i have the current setup for web api
.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ClockSkew = TimeSpan.Zero,
ValidateIssuer = true,
ValidateAudience = true,
ValidateLifetime = true,
ValidateIssuerSigningKey = true,
ValidIssuer = builder.Configuration["JwtSettings:ApplicationID"],
ValidAudience = builder.Configuration["JwtSettings:ApplicationID"],
IssuerSigningKey = new SymmetricSecurityKey(
Encoding.UTF8.GetBytes(builder.Configuration["JwtSettings:SecurityKey"]))
};
})
Now I decided to add Google Auth into my app, so my users dont need to sign up and just use Google. So i added below to my Code..
.AddGoogle(options =>
{
options.ClientId = "xxxxx";
options.ClientSecret = "xxxxx";
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.SaveTokens = true;
options.CorrelationCookie.SameSite = SameSiteMode.Lax;
}).AddCookie(options =>
{
options.LoginPath = "/Account/Unauthorized/";
options.AccessDeniedPath = "/Account/Forbidden/";
});
I can get the token from google upon successfull Login...
var accessToken = await HttpContext.GetTokenAsync(CookieAuthenticationDefaults.AuthenticationScheme, "access_token");
now when i pass this Token to my webapi, it does not get Authenticated. I would like to Authenticate against my webapi using google token same as I am doing with my current setup. is it possible?