Laravel Socialite: InvalidStateException

后端 未结 25 1174
感动是毒
感动是毒 2020-11-27 13:56

I\'m using Laravel Socialite to add a Facebook connect button on a website. Sometimes, I\'ve got this error on callback:

exception \'Laravel\\Socialite\\Two\         


        
25条回答
  •  隐瞒了意图╮
    2020-11-27 14:34

    I ran into this issue last night and solve it with the following solution.

    More information on my issue, I've got

    InvalidStateException in AbstractProvider.php line 182

    in the function handleProviderCallback() when it re-direct back from Facebook login. It seems to be the same as your issue.

    Furthermore I found my issue occurs when I open my site without www. When I open my site with www.mysite.com - no problem. At first I think my issue is random until I've got the clue by Chris Townsend's reply to the question - Thank you very much.

    The Solution

    1. Go to your www root, check the laravel file config/session.php
    2. Check session Session Cookie Domain The default configuration is 'domain' => null, I made a change to 'domain' => 'mysite.com'.
    3. After 'php artisan cache:clear' and 'composer dump-autoload', I can login with no issue from both www.mysite.com and mysite.com

    Be sure to delete your cookies from browser when testing it after these modifications are done. Old cookies can still produce problems.

提交回复
热议问题