Building a custom Google Sign-In button for website ,javascript api ,live or localhost
Building a custom Google Sign-In button for website ,javascript api ,live or localhost
To create a Google Sign-In button with custom settings, add an element to contain the sign-in button to your sign-in page
Create project:
https://console.developers.google.com/projectselector/apis/library
Create credentials
https://console.developers.google.com/apis/credentials
till 3 add in script code.
1 in header use google-signin-client_id
2 https://apis.google.com/js/platform.js
3 https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
4 use below code
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
$("#UserName").val(googleUser.getBasicProfile().getName());
$("#FirstName").val(googleUser.getBasicProfile().getName());
$("#Email").val(googleUser.getBasicProfile().getEmail());
signOut();
}
function signOut() {
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function () {
});
}
Building a custom Google Sign-In button for website ,javascript api ,live or localhost
Reviewed by Code Infosys
on
November 06, 2019
Rating:
No comments