gpt4 book ai didi

php - RuntimeException - session 存储未根据请求设置 - Laravel Socialite - Facebook

转载 作者:行者123 更新时间:2023-12-03 08:58:43 26 4
gpt4 key购买 nike

我正在使用 Laravel 5.7Laravel/Socialite 3.1

我想使用我刚刚为此项目配置的 Facebook 应用程序登录。

这些是我为此配置的主要文件:

/.env

...
FACEBOOK_CLIENT_ID=***
FACEBOOK_CLIENT_SECRET=***
FACEBOOK_CALLBACK_URL=http://localhost:8000/auth/facebook/callback

/config/services.php

<?php

return [
...
'facebook' => [
'client_id' => env('FACEBOOK_CLIENT_ID'),
'client_secret' => env('FACEBOOK_CLIENT_SECRET'),
'redirect' => env('FACEBOOK_CALLBACK_URL'),

],
];

/routes/api.php

<?php

use Illuminate\Http\Request;

...

Route::get('auth/facebook', 'SocialiteController@redirectToProviderFacebook');
Route::get('auth/facebook/callback', 'SocialiteController@handleProviderCallbackFacebook');

/app/Http/Controllers/SocialiteController.php

<?php

namespace App\Http\Controllers;

use Socialite;

class SocialiteController extends Controller
{
public function redirectToProviderFacebook()
{
return Socialite::driver('facebook')->redirect();
}

public function handleProviderCallbackFacebook()
{
$user = Socialite::driver('facebook')->user();
print_r($user->token);
}
}

我的问题是,由于某种原因我收到错误:

RuntimeException
Session store not set on request.

如下图所示:

enter image description here

我根本不想在这个项目上使用 session 。我只想在内部回调中从 Facebook 获取 token:function handleProviderCallbackFacebook()

知道如何解决这个问题吗?

谢谢!

最佳答案

来自社交名流documentation

The stateless method may be used to disable session state verification. This is useful when adding social authentication to an API:

返回 Socialite::driver('google')->stateless()->user();

关于php - RuntimeException - session 存储未根据请求设置 - Laravel Socialite - Facebook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52917631/

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