Laravel Socialite: InvalidStateException
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
- Go to your www root, check the laravel file
config/session.php
- Check session Session Cookie Domain
The default configuration is'domain' => null,
I made a change to'domain' => 'mysite.com'
. - After
'php artisan cache:clear'
and'composer dump-autoload'
, I can login with no issue from bothwww.mysite.com
andmysite.com
Be sure to delete your cookies from browser when testing it after these modifications are done. Old cookies can still produce problems.
Laravel 5.5 \Socialite\Two\InvalidStateException
Try this, I'm using Laravel 5.5:
return Socialite::driver('google')->stateless()->user();
https://laravel.com/docs/5.5/socialite#stateless-authentication
Related Topics
MySQL Code Causes PHP Script to Crash at Popen/Exec
Get Date Range Between Two Dates Excluding Weekends
Mysqli Query Results to Show All Rows
Mechanisms for Tracking Db Schema Changes
PHP - Convert Multidimensional Array to 2D Array with Dot Notation Keys
How to Get Client Ip Address in Laravel 5+
PHP Exec() as Background Process (Windows Wampserver Environment)
Using Strtotime for Dates Before 1970
How to Convert String to Boolean PHP
How to Check If Time Is Between Two Times in PHP
Smtp Server Response: 530 5.7.0 Must Issue a Starttls Command First
Sf2 Form:Error Neither the Property ... Nor One of the Methods "Get