I am trying to integrate Google Sign In into my web app.
My page has the Google button:
ModalDialogue.cshtml:
<a class="google g-signin2" data-onsuccess="onSignIn">Sign up with Google+</a>
I'm trying to trigger that method in my js:
ModalDialogue.js:
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
console.log('Name: ' + profile.getName());
console.log('Image URL: ' + profile.getImageUrl());
console.log('Email: ' + profile.getEmail());
}
I know that
a] the JavaScript is in the scope of the page, since my other functions - for opening and closing the dialogue - DO work.
b] the button is communicating with Google, since clicking on it DOES open the 'sign-in with Google' dialogue - and then once done - changes the button to 'Sign In' afterward.
How do I trigger the onSignIn method? Or at least how do I determine whether onsuccess is being triggered?
Oh. My bad. I hadn't noticed I had the method wrapped in a closure. Needs to be global.
For people who come to this page in the future, I had to move the function definition above the button tag. Seems like it shouldn't matter, as data-onsuccess is simply a string. It didn't throw any error messages, unfortunately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With