【问题标题】:github API oauth with laravel/socialite: doesn't return email带有 laravel/socialite 的 github API oauth:不返回电子邮件
【发布时间】:2015-03-23 09:30:55
【问题描述】:

我正在尝试使用 Laravel Socialite 扩展。

它为 github 生成的 URL 有scope=user%3Aemail:

https://github.com/login/oauth/authorize?client_id=111111&redirect_uri=http%3A%2F%2Flocalhost%3A8880%2Fauth%2Fcallback%2Fgithub&scope=user%3Aemail&state=222222&response_type=code

然后是请求https://api.github.com/user?access_token=$token 除了电子邮件字段之外,响应似乎还可以:它是null。其他字段看起来不错:loginidavatar_url 等...

如何获取用户电子邮件?

【问题讨论】:

    标签: php laravel github oauth-2.0 laravel-5


    【解决方案1】:

    查看 Github 上的 Socialite 文档,它有一个非常简单的方法来重定向和获取整个用户对象。我相信那里会有一封电子邮件。

    https://github.com/laravel/socialite

    【讨论】:

    • 正如我之前提到的,默认范围包含user:email。这似乎是一个错误,我提出了一个拉取请求。
    • @DmitryR 它也不返回名称。
    【解决方案2】:

    我对这个问题提出了拉取请求:

    https://github.com/laravel/socialite/pull/41

    【讨论】:

      【解决方案3】:

      这取决于您的 GitHub 帐户的隐私设置

      【讨论】:

        猜你喜欢
        • 2016-11-03
        • 1970-01-01
        • 1970-01-01
        • 2017-09-04
        • 1970-01-01
        • 1970-01-01
        • 2019-11-07
        • 2017-09-29
        • 1970-01-01
        相关资源
        最近更新 更多