Skip to content

Commit

Permalink
Google Login V2
Browse files Browse the repository at this point in the history
Email extraction from user token
  • Loading branch information
UO287741 committed Feb 28, 2024
1 parent a22b37d commit 29dd022
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions webapp/src/components/GLoginButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,29 @@ const GLoginButton = () => {
const onSuccess = (response: any) => {
console.log( "LOGIN SUCCESS! Current User: ",response.profileObject);
// handle successful login""
var authResponse = response.getAuthResponse();
var accessToken = authResponse.access_token;

//Validations in backend should be done

// Obtener el perfil del usuario
var profile = accessToken.getBasicProfile();

// Obtener el email del usuario
var email = profile.getEmail();
console.log(email);
//send email to backend

};

const onFailure = (error: any) => {
console.log( "LOGIN FAILED! Error: ",error);
// handle failed login
};




return (
<div id='signInButton'>
<GoogleLogin
Expand All @@ -24,8 +40,10 @@ const GLoginButton = () => {
onSuccess={onSuccess}
onFailure={onFailure}
cookiePolicy={'single_host_origin'}
isSignedIn={true}
/>
</div>

)
}

Expand Down

0 comments on commit 29dd022

Please sign in to comment.