github API 使用 laravel/socialite 的 oauth:不 return 电子邮件

github API oauth with laravel/socialite: doesn't return email

我正在尝试使用 Laravel 社交名流扩展程序。

它为 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 等...

如何获取用户邮箱?

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

https://github.com/laravel/socialite

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

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

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