Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Callback not fired on google-sign-in

<html>
<head>
    <meta name="google-signin-client_id" content="MY_CLIENT_ID.apps.googleusercontent.com" />
</head>
<body>
    <div class="g-signin2" data-onsuccess="onSignIn"></div>
    <script src="https://apis.google.com/js/platform.js" async defer></script>
    <script type="text/javascript">
            function onSignIn(googleUser) {
                    console.log("Succesfully Singed in!!!");
            }
    </script>
</body>
</html>

With the above I can see a google-sign-in button which opens a pop-up accepts credential and signs me in. But I expect onSignIn method to be triggered when the sign in is successful, which is NOT happening. Does anyone have any pointers at this?

Tried it on apache server on osx with safari, chrome and firefox browsers

like image 975
Sampath Avatar asked Mar 27 '16 09:03

Sampath


2 Answers

Check Developers Console and see if Authorized redirect URIs is pointing to the origin you are running the JavaScript?

like image 95
agektmr Avatar answered Oct 19 '22 18:10

agektmr


In my case : The callback function was inside the body tag.

Callback function not work if it is in body tag, move it to head tag.

like image 25
Flames Avatar answered Oct 19 '22 18:10

Flames