0

I'm trying to implement Google Sign In in my ASP.net application.
I have implemented the javascript code from Integrating Google Sign-In into your web app and that works but I need to store a Google User ID in my Database for identification in future logins.

The page states that I shouldn't use the profile.getId but I should send the googleUser.getAuthResponse().id_token to the backend and validate this token.

Well I've sent this huge bundle of characters to the backend but I can't seem to figure out how to validate this bundle of characters and retrieve a useful identification ID (which should stay the same for a Google User) from this data bundle.

I've taken a look at:

protected void Page_Load(object sender, EventArgs e)
{
 System.Threading.Tasks.Task<Google.Apis.Auth.GoogleJsonWebSignature.Payload> Sig = Google.Apis.Auth.GoogleJsonWebSignature.ValidateAsync(Request.Form["idToken"], null, true);
 Sig.Wait();
}

But this just hangs in my Page_Load method.

Has anyone got this working?

LiQuick.net
  • 189
  • 15

1 Answers1

0

I'm not sure how you setup your javascript, but the way I have my setup the page already loaded, so I have an API on the backend that receives the token from the client, then do this to get the payload:

GoogleJsonWebSignature.Payload payload = await GoogleJsonWebSignature.ValidateAsync(Token);

The payload will give you all the user's information.

Wen W
  • 2,434
  • 1
  • 10
  • 15