[英]Integration Socialite with Laravel 5.1 InvalidState issue
在Laravel 5.1上安装Socialite插件时遇到问题。
首先,我有这个AuthCOntroller.php代码:
public function redirectToProvider($provider)
{
return Socialite::driver($provider)->redirect();
}
public function handleProviderCallback($provider)
{
//notice we are not doing any validation, you should do it
$user = Socialite::driver($provider)->user();
// stroing data to our use table and logging them in
$data = [
'name' => $user->getName(),
'email' => $user->getEmail()
];
// Here, check if the user already exists in your records
$my_user = User::where('email','=', $user->getEmail())->first();
if($my_user === null) {
Auth::login(User::firstOrCreate($data));
} else {
Auth::login($my_user);
}
//after login redirecting to home page
return redirect($this->redirectPath());
}
和route.php:
Route::get('/social/login/redirect/{provider}', ['uses' => 'Auth\AuthController@redirectToProvider', 'as' => 'social.login']);
Route::get('/social/login/{provider}', 'Auth\AuthController@handleProviderCallback');
现在,当我尝试使用我的域时: http : //mydomain.me/social/login/redirect/facebook
还给我:
http://mydomain.me/social/login/facebook?code=AQAl29aq2-rX9L5-9GmiIwqstR-ETC ETC ETC#_=_
这里有什么问题?
我试图在session.php上将域从null更改为'mydomain.me',还尝试了:
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan clear-compiled
这不再起作用。
/social/login/facebook
获取state
查询字符串,您可以确认可以在重定向URL中看到查询字符串(即,当您看到facebook登录页面时)吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.