[英]Google Authentication in Laravel5.7 php and having “Missing required parameter: code” error 400
[英]Google Authentication in Laravel and having “Missing required parameter: code” error
我正在嘗試為我的網站設置Google身份驗證,但是我遇到了問題:
客戶端錯誤:
POST https://accounts.google.com/o/oauth2/token
導致出現400 Bad Request
響應:\\ n {\\ n“ error”:“ invalid_request”,\\ n
“ error_description”:“缺少必需的參數:code” \\ n } \\ n
這是我的代碼:
public function redirectToProvider(){
return Socialite::driver('google')->redirect();
}
public function handleProviderCallback()
{
$user = Socialite::driver('google')->stateless()->user();
dd($user->getName());
}
有人可以告訴我這是什么問題嗎?
轉到vendor\\laravel\\socialite\\src\\Two\\GoogleProvider.php
從$scopes
刪除'profile'
。 編輯后, $scopes
應該如下所示:
protected $scopes = [
'openid',
'email',
];
注意:在vendor
文件夾中手動更改代碼不是一個好主意。 但是經過大量搜索,我沒有找到解決此問題的好方法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.