0
我在Laravel 5.1上安裝Socialite插件真的很麻煩。與Laravel 5.1集成社交站InvalidState問題
首先,我有這樣的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\[email protected]', 'as' => 'social.login']);
Route::get('/social/login/{provider}', 'Auth\[email protected]');
現在,當我嘗試我的域名:http://mydomain.me/social/login/redirect/facebook
回我:
http://mydomain.me/social/login/facebook?code=AQAl29aq2-rX9L5-9GmiIwqstR-ETC ETC ETC#_=_
這裏有什麼問題?
我嘗試: 域從空在session.php文件更改爲「mydomain.me」,同時也嘗試:
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan clear-compiled
不要再工作......請幫我解決這個問題!
不,我不知道什麼是問題... 10天我試圖解決這個問題! –
你還沒有回答我的任何問題 – fire
1.我的基本登錄工作很好。 2.是的,我看到像.me/social/login/facebook這樣的查詢字符串?code = AQAl29aq2-rX9L5-9GmiIwqstR-ETC ETC ETC#_ = _ 3. fb應用程序正常,一切都按照慣例設置...相同的代碼在其他應用程序的作品很好 –