2
votes

I created a react app with google auth which is working fine. Now I want to check google token to my dotnet core web API and validate it.

I tried services.AddAuthentication with the AddGoogle method but it's not working.

I also tired a middleware https://github.com/khellang/Middleware/tree/master/src/Authentication.JwtBearer.Google. But this is not working as well

services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(x => x.UseGoogle(
    clientId: "<google-client-id>",
    hostedDomain: "<optional-g-suite-domain>"));

Can anyone tell how we can check and validate google token using dotnet core API in c# with [Authorize] attribute?

My React app running on localhost:3000 and API is on localhost:5001

1
I have the same problem. I too have a react app with working client side google authentication. I would like to now secure a web api with authorize attribute and use the related google auth token from UI.Shubhan
I have the same problem and I haven't found a solution yet, did someone find the solution?Michael Horojanski

1 Answers

0
votes

Solved it finally! I setup middleware as defined in http://koscielniak.me/post/2016/04/accesing-api-with-token-from-google-identity-provider/

This works for valid tokens in the api request. For invalid tokens, it does not return but its fine for me ...