google authentification

Web Tips Q & ACategory: Krajee Pluginsgoogle authentification
ibtissem asked 3 weeks ago

Hello,
Thanks for all this great plugin & extensions
I am using yii2-social module , facebook authentification works fine.
i am facing a problem with google authenification, after a sucess sign in i want to save the user in the database user table but i don’t know how to get user information (name,email,profile that i mentioned in the scope setting).
I am waiting for your help.
Thanks. 

1 Answers
ibtissem answered 3 weeks ago

Finallay i found solution, add this in your javascript (i followed this documentation : https://developers.google.com/+/web/people/) :

gapi.load('client', function() { 
gapi.client.load('plus', 'v1').then(function() {
var request = gapi.client.plus.people.get({
'userId': 'me'
});
request.execute(function(resp) {
$.ajax({
url: '".Url::to(['/site/google'], true)."',
type: 'POST',
data: { id: resp.id, email:resp.emails, name:resp.displayName},
dataType : 'json',
success : function(data){
}
});
console.log('Retrieved profile for:' + resp.displayName);
});
});
});

Login or register to contribute or comment.

Login   Register