如何使 google 登录 CakeDC 用户插件的重定向正常工作?

How to make redirection work properly for google login on CakeDC's user plugin?

我正在使用 cakeDC 的用户插件 (8.5.1) 将我的 CakePHP (3.89) 站点限制为仅对我组织的成员开放,并且已遵循以下说明:

https://www.cakedc.com/jorge_gonzalez/2016/10/11/create_google_app_for_web_oauth2_login_step_by_step

https://www.cakedc.com/jorge_gonzalez/2016/10/11/login-with-google-oauth2-in-cakephp-using-cakedc-users-plugin

我将这两行添加到我的 bootstrap.php 文件中,这与说明中所说的略有不同:

Configure::write('Users.config', ['users']); //add this line before Plugin::load('CakeDC/Users...
$this->addPlugin('CakeDC/Users', ['routes' => true, 'bootstrap' => true]);

我的网站是 https://internal.domain.com

如果没有登录,它会重定向到:

https://internal.domain.com/login

登录后,google重定向到

https://internal.domain.com/auth/google?state=XXXXXXX&code=4/XXXXXXX&scope=XXXXXX&authuser=XXXX&hd=XXXXXX&prompt=XXXX&session_state=XXXXXX

它不能作为一个页面工作,那是在 cake 中没有为它设置路由:

数据库错误 PDO异常 错误:SQLSTATE[22001]:字符串数据,右截断:1406 第 1 行 'avatar' 的数据太长

从日志中我可以看到用户没有登录,所以这让我相信我在安装中做错了什么。

是这里重定向到错误的页面还是插件安装不正确? Google 不允许我将 redirect_uri 更改为其他任何内容,也就是说,如果我在那里放置不同的地址,它会说登录时 uri_redirect 不匹配并给我link 到控制台修复它。

已添加特定路线以匹配您在此处启用社交登录的所有提供商https://github.com/CakeDC/users/blob/8.5.1/config/bootstrap.php#L37

请检查路由是否通过 bin/cake routes 正确创建并且 google 提供商配置是否正确设置,请参阅 https://github.com/CakeDC/users/blob/8.5.1/Docs/Documentation/SocialAuthenticate.md#setup