gpt4 book ai didi

php - Laravel 社交名媛 : Laravel\Socialite\Two\InvalidStateException

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:49:11 25 4
gpt4 key购买 nike

我是 Laravel Socialite 的新手,从社交媒体登录重定向回来时出现此错误

Laravel\Socialite\Two\InvalidStateException in/vendor/laravel/socialite/src/Two/AbstractProvider.php:209**

即使我已经尝试过这个解决方案 https://stackoverflow.com/a/31738836/4428431但我仍然面临同样的错误。

这里是社交名流 Controller 的代码

// Redirect to Social provider for login
public function redirectToProvider($provider)
{
return Socialite::driver($provider)->redirect();
}

// Handling get request from social provider
public function handleProviderCallback($provider, Request $request)
{
$user = Socialite::driver($provider)->user();
}

实际上代码在一开始是有效的,但在我将非 www 重定向到 www 后它停止了工作。这里是 .htaccess 文件

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^ index.php [L]
RewriteRule .* index.php?/$0 [PT,L]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#RewriteCond %{HTTPS} !on
#RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>

最佳答案

我遇到了同样的问题并通过添加 ->stateless() 修复了

$user = Socialite::driver( $provider )->stateless()->user();

关于php - Laravel 社交名媛 : Laravel\Socialite\Two\InvalidStateException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47516472/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com