1

我使用 OAuth2 进行了 Google 登录。

我使用的范围是用户信息。但我只从对象返回中获取 id。

我应该得到这样的东西:

{
 "id": "<some-id>,
 "email": "<correct-email-id>",
 "verified_email": true,
 "name": "blabla",
 "given_name": "blabla",
 "family_name": "blabla",
 "link": "<link>",
 "gender": "male",
 "locale": "en"
}

但我只得到:

{
 "id": "<some-id>
}

我试过了:

https://www.googleapis.com/oauth2/v1/userinfo?access_token=<access-token>
https://www.googleapis.com/oauth2/v2/userinfo?access_token=<access-token>

这是电话:

$.ajax({
            type: 'GET',
            url: 'https://www.googleapis.com/oauth2/v1/userinfo?access_token=' + accesstoken,
            async: false,
            contentType: 'json',
            success: function(result) {
              profileemail = result.email;
              console.log(result);  
            },
            error: function(e) {
              console.log(e);
            }
          });
4

1 回答 1

2

确保您请求配置文件范围。请参阅: https ://developers.google.com/accounts/docs/OAuth2Login#obtaininguserprofileinformation

于 2013-08-05T17:55:02.617 回答