Call data-onsuccess to log in to Google

I am trying to integrate Google Login into my web application.

There is a Google button on my page:

ModalDialogue.cshtml: <a class="google g-signin2" data-onsuccess="onSignIn">Sign up with Google+</a> 

I am trying to call this method in 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] JavaScript is in the page area, since my other functions - opening and closing the dialog - DO work.

b] the button interacts with Google, as clicking on it opens the "login with Google" dialog, and then after that - after that the "Login" button changes.

How to call the onSignIn method? Or at least how to determine if onsuccess is starting?

+4
source share
2 answers

O. Guilty. I did not notice that I had a method wrapped in closure. You need to be global.

+2
source

For people who came to this page in the future, I had to move the function definition above the button tag. It doesn't seem to matter, since data-onsuccess is just a string. Unfortunately, he did not give any error messages.

+1
source

All Articles