Cordial greeting I want to be able to capture data such as the basics (name, surname, email ...) and more specific ones such as the birthday and gender; this through a login button. All good with the basic data (I put code below). But I do not know how to capture the birth date and gender data. Inquiring I stumbled upon what I can do with the Google People API. But I'm new to APIs and I really can not understand how to capture variables by this means.
With this I have been able to capture the basic data
<script src="https://apis.google.com/js/api:client.js"></script>
<script>
var googleUser = {};
var startApp = function() {
gapi.load('auth2', function(){
// Retrieve the singleton for the GoogleAuth library and set up the client.
auth2 = gapi.auth2.init({
client_id: 'xxx.apps.googleusercontent.com',
cookiepolicy: 'single_host_origin',
// Request scopes in addition to 'profile' and 'email'
scope: 'https://www.googleapis.com/auth/user.birthday.read'
});
attachSignin(document.getElementById('customBtn'));
});
};
function attachSignin(element) {
console.log(element.id);
auth2.attachClickHandler(element, {},
function(googleUser) {
var profile = googleUser.getBasicProfile();
document.getElementById('name').innerText = "Signed in: " +
profile.getName();
}, function(error) {
alert(JSON.stringify(error, undefined, 2));
});
}
</script>