简体   繁体   English

Laravel 社交名流:Laravel\Socialite\Two\InvalidStateException

[英]Laravel Socialite: Laravel\Socialite\Two\InvalidStateException

I want to create social login using Google and Facebook.我想使用 Google 和 Facebook 创建社交登录。 In the first step, I want to create Google Login.第一步,我想创建 Google 登录。 When I select the Google ID and Callback it shows me this error.当我选择 Google ID 和回调时,它会显示此错误。

Laravel\Socialite\Two\InvalidStateException
http://localhost:8000/customer/login/google/callback?authuser=1&code=4%2F0AX4XfWgtwfNmX20WgsbTWXCO0joa1BrfjX0Iif1jqoxTqvT-AqwRVRgwyJwR95EuFlBx9Q&prompt=consent&scope=email%20profile%20openid%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&state=e7PCC5OnNvtkQ6e7GBquKsTtAjWYiIuMdFZ477Kt 

URL :网址:

Route::get('/customer/login/google/callback', 'handleGoogleCallback')->name('callback.to.google');

Controller :控制器 :

 public function handleGoogleCallback() {
        try {
            $user = Socialite::driver('google')->user();
            dd($user);
        } catch (\Throwable $th) {
            throw $th;
        }
    }
'google' => [
        'client_id' => env('GOOGLE_CLIENT_ID'),
        'client_secret' => env('GOOGLE_CLIENT_SECRET'),
        'redirect' => 'http://localhost:8000/customer/login/google/callback',
    ],
GOOGLE_CLIENT_ID="xxxxxxxxxxxxx-xxxxxxxxxxxxxx.apps.googleusercontent.com"
GOOGLE_CLIENT_SECRET="GOCSPX-qzx7jVkboSS_xxxxxxxxxxxxx"

How to solve this problem??如何解决这个问题呢??

Your state is incorrect.你的state不正确。 state is a parameter that laravel-socialite added to auth request once you did /redirect. state是 laravel-socialite 在执行 /redirect 后添加到身份验证请求的参数。 Seems like you trying complete auth operation two+ times from just only google.com request.似乎您仅从 google.com 请求中尝试了两次以上的完整身份验证操作。 Retry auth from /redirect request.从 /redirect 请求重试身份验证。

PS. PS。 sorry for my English对不起我的英语不好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM