【问题标题】:Get google people profile API does not return birthday and gender key values获取 google people profile API 不返回生日和性别键值
【发布时间】:2023-03-26 07:22:01
【问题描述】:

GPPSignIn *signIn;

在我的 iOS 应用中,我将范围设置为:

signIn.scopes = @[@"https://www.googleapis.com/auth/plus.login",
                  @"https://www.googleapis.com/auth/plus.me",
                  @"https://www.googleapis.com/auth/plus.profile.emails.read", 
                  @"email",
                  @"profile",
                  @"https://www.googleapis.com/auth/user.birthday.read"];

还有,

signIn.shouldFetchGoogleUserEmail = YES;
signIn.shouldFetchGooglePlusUser = YES;

并试图从 Google 获取 access_token。我获取并发送到服务器。

现在,我的服务器正在这样做:

client = OAuth2::Client.new('app_id', 'app_secret')
access_token = OAuth2::AccessToken.new(client, access_token)
profile_api_url = 'https://www.googleapis.com/plus/v1/people/me'
response = access_token.get(profile_api_url)
google_profile_res_body = JSON.parse(response.body)

这里,google_profile_res_body 有许多属性,但没有生日和性别。

有人知道吗?请建议。提前致谢。

干杯, 拉胡尔

【问题讨论】:

  • 更新:创建的新帐户没有这些属性,但我用一年和 4 年前创建的帐户进行了测试,google apis 返回了这两个字段,很奇怪吧?!!

标签: ios objective-c ruby google-api google-people-api


【解决方案1】:

问题可能在于,仅当字段已设置为具有 public 可见性时,才会返回生日和性别。不会返回私有可见性字段。

如果您使用不同于 G+ People APIGoogle People API,您应该能够获得具有https://www.googleapis.com/auth/user.birthday.read 范围的私人生日。不幸的是,没有私人的性别范围。

有关更多信息,请参阅https://developers.google.com/people/ 上的 Google People API 文档。

【讨论】:

  • 我已经在我的谷歌账户设置中公开了生日和性别。所以,我认为这不是问题。我想,这是因为我在对我的问题的评论中提到的原因。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-03
  • 1970-01-01
  • 2021-07-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多