Hello I am using google api to sign in to my web application . Now Its working fine . But the problem is the sigin is initiated automatically as I go to my log in page . But I do not want that . I want the user to click the signin button first then the process will start .
I am using below button
<div class="g-signin2" data-onsuccess="onSignIn"></div>
and google log in references .
To create a Google Sign-In button with custom settings, add an element to contain the sign-in button to your sign-in page, write a function that calls signin2. render() with your style and scope settings, and include the https://apis.google.com/js/platform.js script with the query string onload=YOUR_RENDER_FUNCTION .
Add Google Sign-In to Your Web App console. log("ID: " + profile. getId()); // Don't send this directly to your server!
Use 'attachClickHandler' to Initiate Google Sign In.
<script src="https://apis.google.com/js/client:platform.js?onload=init" async defer></script>
<script>
function init() {
gapi.load('auth2', function() {
auth2 = gapi.auth2.init({
client_id: '*************.apps.googleusercontent.com',
cookiepolicy: 'single_host_origin',
scope: 'profile email'
});
element = document.getElementById('glogin');
auth2.attachClickHandler(element, {}, onSignUp, onFailure);
});
}
function onSignUp(googleUser) {
var profile = googleUser.getBasicProfile();
}
</script>
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