I am using react-google-login library to let users sign in my application on the client-side through Google, which works fine and returns token and profile information.
<GoogleLogin
clientId="XXXX.apps.googleusercontent.com"
buttonText="Login"
onSuccess={responseGoogle}
onFailure={responseGoogle}
cookiePolicy={'single_host_origin'}
/>
const responseGoogle = (response) => {
console.log(response);
}
Below is the configuration on the server to enable Google Authentication:
services.AddAuthentication()
.AddGoogle(options =>
{
IConfigurationSection googleAuthNSection =
Configuration.GetSection("Authentication:Google");
options.ClientId = googleAuthNSection["ClientId"];
options.ClientSecret = googleAuthNSection["ClientSecret"];
});
But, I do not how to transfer this successful login to the asp.net server-side. How can I use the token sent by google to sign in the user on the server side? I would like to do this for two cases: (a) the email in the system does not match the gmail, (b) the email in the system matches the gmail. I appreciate any help.