使用 Google OAuth API 检索出生日期和婚姻状况 [英] Retrieving date of birth and marital status with Google OAuth API
问题描述
我正在尝试通过 Google OAuth api 检索出生日期和婚姻状况.我通过将范围设置为 https://www.googleapis.com/auth/来获得以下提到的信息userinfo.profile &https://www.googleapis.com/auth/userinfo.email.请求 URL 为 https://www.googleapis.com/oauth2/v2/userinfo
I'm trying to retrieve date of birth and marital status via Google OAuth api. I get below mentioned info by setting the scopes as https://www.googleapis.com/auth/userinfo.profile & https://www.googleapis.com/auth/userinfo.email . Request URL is https://www.googleapis.com/oauth2/v2/userinfo
{
"id": "my_id",
"email": "test@gmail.com",
"verified_email": true,
"name": "full_name",
"given_name": "first_name",
"family_name": "last_name",
"link": "https://plus.google.com/xxxxxxx",
"picture": "https://xxxxxxxxx/photo.jpg",
"gender": "male",
"locale": "en"
}
我在个人资料中设置了生日和婚姻状况,但我无法获取此信息.可能是什么问题?
I have birthday and marital status set in my profile, but I'm unable to get this info. What could the problem be?
推荐答案
将范围设置为
https://www.googleapis.com/auth/plus.login
并且请求 url 是
and request url is
https://www.googleapis.com/plus/v1/people/me
注意:-关系状态和生日仅对您可用如果用户将它们设为公开.
NOTE:- Relationship Status and Birthday only available to you if user set them public.
看看这个 google api explorer.
我已经尝试使用 grails oauth 插件 并公开我的生日和关系状态它给了我
I have tried this using grails oauth plugin and make my birthday and relationship status public it gives me
[birthday:1988-04-02, ..., relationshipStatus:single, ...]
编辑 ...........................................................................
Q. New problem with email, I can't get it after changes
您可以设置多个范围,例如:
You can set multiple scopes like:
https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/plus.login
并提出两个请求,一个是生日和关系状态
and make two requests one for birthday and relationship status
https://www.googleapis.com/plus/v1/people/me
另一个用于电子邮件
https://www.googleapis.com/oauth2/v2/userinfo
这篇关于使用 Google OAuth API 检索出生日期和婚姻状况的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!