google one tap login popup

Hi,

I am trying to have google one tap login popup but its not showing up. Here is my code:


in my index page:

data-client_id="???"

data-login_uri='/google-response'>


in my controller page:

[Route("google-response")]

public async Task GoogleResponse()

{


var google_csrf_name = "g_csrf_token";

var cookie = Request.Cookies[google_csrf_name];

if (cookie == null)

return StatusCode((int)HttpStatusCode.BadRequest);


var requestbody = Request.Form[google_csrf_name];


if (requestbody != cookie)

return StatusCode((int)HttpStatusCode.BadRequest);


var idtoken = Request.Form["credential"];

GoogleJsonWebSignature.Payload payload = await GoogleJsonWebSignature.ValidateAsync(idtoken).ConfigureAwait(false);


TempData["name"] = payload.Name;

TempData["email"] = payload.Email;

return Json(payload);


}

in appsettingsjson:

"GoogleAuthSettings": {
"ClientId": "???",
"ClientSecret": "???"
}

I added the following packages: Google.Apis.Auth and Microsoft.AspNetCore.Authentication.Google
I try to run the above but nothing is showing. Can you help. Thanks

1 Reply

BH BharatRam Harikrishnan Syncfusion Team September 19, 2023 02:22 PM UTC

Hi Rami,


Regarding the configuration of Google One Tap login in an ASP.NET Core app:

 

You can refer to the following resource:

 

https://learn.microsoft.com/en-us/aspnet/core/security/authentication/social/google-logins?view=aspnetcore-7.0

 

This is a general query. Please feel free to get back to us if you have any concerns related to Syncfusion products.

 

Regards,

Bharat Ram H


Loader.
Up arrow icon