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