some of the users on my site are experiencing
a Laravel\Socialite\Two\InvalidStateException
. I've taken the steps outlined in the replies to Laravel Socialite: InvalidStateException and have not been able to resolve the issue. Only a small percentage of users seem to be experiencing this.
I have 2 fpm/nginx docker containers sitting behind an HAProxy load balancer.
Route::get('login/github', function() { return Socialite::driver('github')->stateless()->redirect(); }); Stateless just means there is no sessions stored. When they user completes their login, github redirects the user back to the callback you register with them earlier.
This seems to be an invalid state issue in socialite package that is already resolved in this post.
Some of your users are accessing your website with a different url (https://www.example.com or https://example.com) hence causing the mismatching "state" in the sessions.
If you are on Larvel 5.3 and above... add a SESSION_DOMAIN=http://example.com
in the .env
file
For other versions go to your config/session.php
file, and add your domain. 'domain' => 'www.example.com'
To apply changes immediately. Run 'php artisan cache:clear'
and 'composer dump-autoload'
Hopefully this should resolve the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With