如何使用Meteor.loginWithGoogle获取Google+个人资料? [英] How to get Google+ profile with Meteor.loginWithGoogle?
问题描述
我正在寻找Meteor.loginWithGoogle(使用流星0.6.4.1)的工作示例.
我找到了这个用于loginWithGitHub( https://www.eventedmind.com/posts /meteor-customizing-login )与GitHub配合使用.
它没有参数就可以正常工作,如客户端所示:
Template.user_loggedout.events({
"click #login": function(e, tmpl){
Meteor.loginWithGoogle({
}, function (err) {
if(err) {
//error handling
alert('error : '+err.message);
} else {
}
});
}
});
帐户"参数位于服务器端:
Accounts.loginServiceConfiguration.remove({
service: 'google'
});
Accounts.loginServiceConfiguration.insert({
service: 'google',
clientId: 'XXXXXX',
secret: 'YYYYYY'
});
在这种情况下,我如何获得currentUser信息,尤其是邮件? 有没有一种方法可以获取用户的Google+个人资料(如果他有个人资料并允许这样做),例如用户的头像? requestPermissions:所需的参数是什么,我可以从中得到什么?
谢谢
经过研究,我在这里建立了自己的示例: https://github.com/m2web/githublogin
https://github.com/ananta-IO/marq
https://developers.google.com/accounts/docs/OAuth2Login#obtaininguserprofileinformation
I'm looking for a working example of Meteor.loginWithGoogle (with meteor 0.6.4.1).
I found this one for loginWithGitHub (https://www.eventedmind.com/posts/meteor-customizing-login) that works fine with GitHub.
It works fine without parameters as show here on client side :
Template.user_loggedout.events({
"click #login": function(e, tmpl){
Meteor.loginWithGoogle({
}, function (err) {
if(err) {
//error handling
alert('error : '+err.message);
} else {
}
});
}
});
with the Accounts params on server side :
Accounts.loginServiceConfiguration.remove({
service: 'google'
});
Accounts.loginServiceConfiguration.insert({
service: 'google',
clientId: 'XXXXXX',
secret: 'YYYYYY'
});
In this case how can i get currentUser information especially the mail ? Is there a way to get the Google+ profile of the user (if he has one and allows this), the user's avatar for example ? What are the needed parameters for requestPermissions: , what can i get with this ?
Thanks
After some research i build my own example available here : https://github.com/lc3t35/googlelogin
Thanks to :
https://github.com/m2web/githublogin
https://github.com/ananta-IO/marq
Meteor/MongoDB see available fields for publish?
https://developers.google.com/accounts/docs/OAuth2Login#obtaininguserprofileinformation
这篇关于如何使用Meteor.loginWithGoogle获取Google+个人资料?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!