google+ api 是 Laravel 的 Socialite OAuth 所必需的吗?以及如何限制权限?
Is google+ api necessary for Laravel's Socialite OAuth ? And also how to limit permissions?
我在 Laravel 5.1 项目中使用 Socialite。
将 Google OAuth 与社交名流一起使用需要强制启用 Google+ api
否则它会抛出
ClientException in Middleware.php line 69:Client error: 403
即使在禁用 Google Api 之后我仍然看到这个屏幕
不想询问他们 CIRCLE
中的成员。
我只想要 Socialite 返回的字段 -
Id, Nickname, Name, email-id & Avatar
同意屏幕中的权限由您发送的范围控制。您可能发送 scope 个 https://www.googleapis.com/auth/plus.login
。删除它并向用户请求权限,但您也将无法访问那里的 Google+ 数据。
此外,您无法更改范围授予的权限,这些权限由 Google 提供。如果你想要的只是个人 ID、昵称、姓名、电子邮件地址,你可以尝试配置文件范围,我认为它为你提供了这些信息,但你应该检查文档并自己测试。
vendor/laravel/socialite/src/Two/GoogleProvider.php
改变
$scopes = [ 'https://www.googleapis.com/auth/plus.me',
'https://www.googleapis.com/auth/plus.login', 'https://www.googleapis.com/auth/plus.profile.emails.read', ];
至
$scopes = ['https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile', ];
我在 Laravel 5.1 项目中使用 Socialite。
将 Google OAuth 与社交名流一起使用需要强制启用 Google+ api
否则它会抛出
ClientException in Middleware.php line 69:Client error: 403
即使在禁用 Google Api 之后我仍然看到这个屏幕
不想询问他们 CIRCLE
中的成员。
我只想要 Socialite 返回的字段 -
Id, Nickname, Name, email-id & Avatar
同意屏幕中的权限由您发送的范围控制。您可能发送 scope 个 https://www.googleapis.com/auth/plus.login
。删除它并向用户请求权限,但您也将无法访问那里的 Google+ 数据。
此外,您无法更改范围授予的权限,这些权限由 Google 提供。如果你想要的只是个人 ID、昵称、姓名、电子邮件地址,你可以尝试配置文件范围,我认为它为你提供了这些信息,但你应该检查文档并自己测试。
vendor/laravel/socialite/src/Two/GoogleProvider.php
改变
$scopes = [ 'https://www.googleapis.com/auth/plus.me',
'https://www.googleapis.com/auth/plus.login', 'https://www.googleapis.com/auth/plus.profile.emails.read', ];
至
$scopes = ['https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile', ];