Validation of Google User Token in the back end

Asked

Viewed 15 times

0

I’m facing a problem and I’ve already lost hours on forums and on google certification, but I can’t find the solution. I have the following scenario:

  1. A front-end that is from a third company logs in through the google service, an application in Firebase, authenticating the user and making a request for my back-end, where it sends me the accessToken (JWT Token).

  2. In the back-end I pick up the accessToken and need to fetch user information. I am using the official google library to . Net (Google.Apis.Oauth2.v2). However, when the code below is exceeded, I get the error from Badrequest - Error Response is null.

     try
     {                
         Oauth2Service service = new Oauth2Service(new BaseClientService.Initializer());
         Oauth2Service.TokeninfoRequest request = service.Tokeninfo();
         request.AccessToken = token;
    
         Tokeninfo info = await request.ExecuteAsync();
         return info.UserId;
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
    
     return string.Empty;
    

When executing the above code I get the following error: inserir a descrição da imagem aqui

If someone has already been through the same problem, or has an accessToken verification solution in the back end and can help, I would appreciate it. Hugs.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.