I have set a google login which is on a lightbox.
What code do I need to close the lightbox after a successful login from Google?
And how do I transfer the received data from Google to the member list?
Only code what i have is this in iFrame here:
<!doctype html>
<html>
<head>
<meta name="google-signin-client_id" content="CLIENT_ID.apps.googleusercontent.com">
<script>
</script>
</head>
<body>
<div id="my-signin2"></div>
<script>
function onSuccess(googleUser) {
var profile = googleUser.getBasicProfile();
let userId = profile.getId();
let fullName = profile.getName();
let firstName = profile.getGivenName();
let lastName = profile.getFamilyName();
let userEmail = profile.getEmail();
let idToken = googleUser.getAuthResponse().id_token;
window.parent.postMessage({userId: (userId), idToken: (idToken),fullName: (fullName), firstName: (firstName), lastName: (lastName),userEmail: (userEmail)}, "*");
//here we auto sign out the user as we have already posted their info to the page code, remove this part of the code if you want the user to remain signed into google on your page
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut();
}//end of googleSignIn
function onFailure(error) {
console.log(error);
}
//custom google button
function renderButton() {
gapi.signin2.render('my-signin2', {
'scope': 'profile email',
'width': 240,
'height': 50,
'longtitle': true,
'theme': 'dark',
'onsuccess': onSuccess,
'onfailure': onFailure
});
}
</script>
<script src="https://apis.google.com/js/platform.js?onload=renderButton" async defer></script>
</body>
</html>
Can one give me the code, unfortunately I do not know myself so well.
How to close a lightbox.....
import wixWindow from 'wix-window'; wixWindow.lightbox.close();
Could you solve this issue already?