获取 google 个人资料 API 不获取 return 生日和性别键值
Get google people profile API does not return birthday and gender key values
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
有很多属性,但没有生日和性别。
有人知道吗?请建议。提前致谢。
干杯,
拉胡尔
可能的问题是只有在字段设置为具有 public 可见性时才会返回生日和性别。不会返回私有可见性字段。
如果您使用的 Google 人 API 不同于 G+ 人 API, 你应该可以得到 https://www.googleapis.com/auth/user.birthday.read
范围内的私人生日。不幸的是,性别没有私有范围。
有关详细信息,请参阅 https://developers.google.com/people/ Google 人 API 的文档。
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
有很多属性,但没有生日和性别。
有人知道吗?请建议。提前致谢。
干杯, 拉胡尔
可能的问题是只有在字段设置为具有 public 可见性时才会返回生日和性别。不会返回私有可见性字段。
如果您使用的 Google 人 API 不同于 G+ 人 API, 你应该可以得到 https://www.googleapis.com/auth/user.birthday.read
范围内的私人生日。不幸的是,性别没有私有范围。
有关详细信息,请参阅 https://developers.google.com/people/ Google 人 API 的文档。