我在使用 Laravel Socialite 通过 Google API 登录用户时遇到了这个奇怪的问题。
一切配置看起来都很正常和普通,但我不断收到错误消息Missing required parameter: client_id
。不仅如此,有时我再试一次,Missing required parameter: redirect_uri
尽管提供了所有这些参数,但错误仍然存在。
这是它的设置方式:
服务.php
'google' => [
'client_id' => 'xxxxxxxxxx-x98asxxxx913ofk5tqvgq7lqfpgdi5u2.apps.googleusercontent.com',
'client_secret' => 'mklOWJFhpbCzTKxxxx-xxxx',
'redirect' => 'http://myapp.com/auth/google/callback'
],
路由.php
Route::get('/auth/{social_channel}', 'Auth\AuthController@redirect_to_provider');
Route::get('/auth/{social_channel}/callback', 'Auth\AuthController@handle_provider_callback');
AuthController.php
/**
* Redirect the user to the Google authentication page.
*
* @return Response
*/
public function redirect_to_provider($social_channel)
{
return Socialite::driver($social_channel)->redirect();
}
/**
* Obtain the user information from GitHub.
*
* @return Response
*/
public function handle_provider_callback($social_channel, SocialAccountService $service)
{
$user = $service->create_or_get_user($social_channel, Socialite::driver($social_channel)->user());
Auth::login($user);
return redirect()->to('/go');
}
Facebook 登录对我有用,只是这个 Google 登录问题是一个顽固而奇怪的问题。
该应用程序部署在 Forge(Ubuntu、Nginx)上。
有人能发现这有什么问题吗?