簡體   English   中英

Laravel中的Google身份驗證,並顯示“缺少所需參數:代碼”錯誤

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM