Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 使用google登录在我的网站上登录后获取google帐户信息(使用satellizer lib登录)_Angularjs_Node.js_Mongodb_Google Api_Satellizer - Fatal编程技术网

Angularjs 使用google登录在我的网站上登录后获取google帐户信息(使用satellizer lib登录)

Angularjs 使用google登录在我的网站上登录后获取google帐户信息(使用satellizer lib登录),angularjs,node.js,mongodb,google-api,satellizer,Angularjs,Node.js,Mongodb,Google Api,Satellizer,我已经使用和节点服务器在我的网站上使用google sing in登录 我已经成功登录并在mongodb数据库中添加了以下数据 { "_id" : ObjectId("57adec45a8fb51401c1ba843"), "displayName" : "xyz user", "picture" : "https://lh3.googleusercontent.com/-xxxxxxx_xx/xxxxxx/xxxxxxx/xxxxxxx/photo.jpg?sz=200

我已经使用和节点服务器在我的网站上使用google sing in登录

我已经成功登录并在mongodb数据库中添加了以下数据

{
    "_id" : ObjectId("57adec45a8fb51401c1ba843"),
    "displayName" : "xyz user",
    "picture" : "https://lh3.googleusercontent.com/-xxxxxxx_xx/xxxxxx/xxxxxxx/xxxxxxx/photo.jpg?sz=200",
    "google" : "100379763204xxxxxxxxx", //user id
    "__v" : 0
} 
现在,我想从谷歌账户上获取其他信息,如性别、电话号码、位置等


那么,如何从google帐户获取登录用户的所有信息呢?

并非所有信息都是可用的。它还将取决于用户是否已将信息设置为公共信息

如果使用该方法,它将返回一个person资源。假设用户公开了此信息,您应该会看到您要查看的信息。此方法是Google+api的一部分,因此它仅在用户拥有Google+帐户时才起作用


还有People API,它倾向于返回类似的信息。我不确定这些信息到底是从哪里来的。它似乎与用户的Google帐户有关,而不是Google+帐户

我终于成功了,我的解决方案是:

getGoogleDatas: function (id) {
    return $http.get("https://www.googleapis.com/oauth2/v1/userinfo", {
        params: {
            access_token: $auth.getToken(),
            alt: 'json'
        }
    });
}
然后:

getGoogleDatas().then(function (response) {
    user = response;
}).catch(function (error) {
    console.log('error:', error);
});

我想这已经在这里得到了回答。。