【问题标题】:Retrieving date of birth and marital status with Google OAuth API使用 Google OAuth API 检索出生日期和婚姻状况
【发布时间】:2013-11-05 21:37:09
【问题描述】:

我正在尝试通过 Google OAuth api 检索出生日期和婚姻状况。通过将范围设置为 https://www.googleapis.com/auth/userinfo.profilehttps://www.googleapis.com/auth/userinfo.email ,我得到了下面提到的信息。请求地址为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"
}

我的个人资料中设置了生日和婚姻状况,但我无法获取此信息。可能是什么问题?

【问题讨论】:

    标签: grails oauth oauth-2.0 google-oauth


    【解决方案1】:

    将范围设置为

    https://www.googleapis.com/auth/plus.login
    

    请求网址是

    https://www.googleapis.com/plus/v1/people/me
    

    注意:-关系状态和生日仅对您可用如果用户将它们设为公开

    看看这个google api explorer

    我已经尝试过使用grails oauth plugin 并公开我的生日和关系状态,它给了我

    [birthday:1988-04-02, ..., relationshipStatus:single, ...]
    

    编辑.......................... ....................................

    Q. New problem with email, I can't get it after changes
    

    您可以设置多个范围,例如:

    https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/plus.login
    

    并提出两个请求,一个是生日和关系状态

    https://www.googleapis.com/plus/v1/people/me
    

    另一个用于电子邮件

    https://www.googleapis.com/oauth2/v2/userinfo
    

    【讨论】:

    • 非常好,感谢您的帮助,但我只是想知道,当我在个人资料中隐藏出生年份时,我收到的是 0000 而不是它。这有点奇怪,因为实际上我不需要没有年份的月份和日期。
    • 是的,但是google有点笨。无论如何感谢您的帮助。
    • 邮箱新问题,修改后收不到。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-16
    • 2012-06-25
    • 1970-01-01
    • 1970-01-01
    • 2012-01-11
    • 2013-08-31
    相关资源
    最近更新 更多