如何使用 Meteor.loginWithGoogle 获取 Google+ 个人资料? [英] How to get Google+ profile with Meteor.loginWithGoogle?

查看:20
本文介绍了如何使用 Meteor.loginWithGoogle 获取 Google+ 个人资料?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找 Meteor.loginWithGoogle 的工作示例(使用meteor 0.6.4.1).

我为 loginWithGitHub 找到了这个 (https://www.eventedmind.com/posts/meteor-customizing-login) 在 GitHub 上运行良好.

它在没有参数的情况下工作正常,如客户端所示:

Template.user_loggedout.events({点击#login":函数(e,tmpl){Meteor.loginWithGoogle({}, 函数(错误){如果(错误){//错误处理alert('错误:'+err.message);} 别的 {}});}});

使用服务器端的帐户参数:

Accounts.loginServiceConfiguration.remove({服务:谷歌"});Accounts.loginServiceConfiguration.insert({服务:谷歌",客户 ID: 'XXXXXX',秘密:'YYYYYY'});

在这种情况下,我如何获取当前用户信息,尤其是邮件?有没有办法获取用户的 Google+ 个人资料(如果他有一个并允许这样做),例如用户的头像?requestPermissions: 需要什么参数,我能得到什么?

谢谢

解决方案

经过一些研究,我构建了自己的示例,可在此处使用:https://github.com/lc3t35/googlelogin

感谢:

https://github.com/m2web/githublogin

https://github.com/ananta-IO/marq

Meteor/MongoDB 查看可发布的字段?>

https://github.com/mrtnbroder/meteor-snippets/blob/master/snippets/js/Accounts/loginWithGoogle.sublime-snippet

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://github.com/mrtnbroder/meteor-snippets/blob/master/snippets/js/Accounts/loginWithGoogle.sublime-snippet

https://developers.google.com/accounts/docs/OAuth2Login#obtaininguserprofileinformation

这篇关于如何使用 Meteor.loginWithGoogle 获取 Google+ 个人资料?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆