10

有谁知道如何通过 Google OAuth api 检索 DOB?我可以通过将范围设置为https://www.googleapis.com/auth/userinfo.profile来获取其他信息,例如姓名、电子邮件、性别。但我无法在这个范围内获得 DOB。

4

2 回答 2

9

我肯定会为我的帐户获得它:

{
  "id": "108635752367054807758",
  "name": "Nicolas Garnier",
  "given_name": "Nicolas",
  "family_name": "Garnier",
  "link": "https://plus.google.com/108635752367054807758",
  "picture": "https://lh4.googleusercontent.com/-K1xGP8W20xk/AAAAAAAAAAI/AAAAAAAABhY/Cs_4qr30MxI/photo.jpg",
  "gender": "male",
  "birthday": "0000-08-25",
  "locale": "en"
}

我所做的只是授权https://www.googleapis.com/auth/userinfo.profile范围,然后向https://www.googleapis.com/oauth2/v2/userinfo发送 GET 请求

首先确保您正在测试的 Google+ 帐户设置了生日(当然),然后在 OAuth 2.0 Playground 上尝试请求,例如:https ://code.google.com/oauthplayground/#step1&apisSelect=https% 3A//www.googleapis.com/auth/userinfo.profile&url=https%3A//www.googleapis.com/oauth2/v2/userinfo

于 2012-06-12T18:54:39.493 回答
4

看来您必须发送 2 个请求:

获取 google plus 个人资料数据和 google 帐户数据(如果需要,还有生日日期和区域设置)

我使用抄写员,它工作正常。设置两个范围(“https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/plus.me ”)并为两个 REST 链接发送两个请求

于 2012-08-23T02:17:04.770 回答