Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vk011's avatar
Level 1

Socialite google works on localhost only

Hi guys, I asked about issues with Google oauth a while back but got no answers, and made some progress in the meantime.

I have facebook and google login using socialite, facebook works but google I've only managed to get to work locally, so for example locally the url is http://dev.thesite.com and in production the url is https://thesite.com, that's the only difference, however when trying to log in with google in production i always get the invalidState exception

I managed to make some "progress" by setting the callback url to be https://www.thesite.com//login/google/callback instead of just /login/google/callback and also having www in the url in the google api console for the callback, then I don't get an error but I am redirected wrongly to /index.php and I am not really signed in.

My .htaccess files redirects all requests to https, I believe that maybe some server setting is the issue here, did you guys have any similar experiences?

0 likes
3 replies
Wraith's avatar

go to config/session.php and set (without www)

'domain' => env('SESSION_DOMAIN', yourdomain.com),

and in console

php artisan cache:clear
composer dump-autoload

Delete all cookies from browser

vk011's avatar
Level 1

Hi, tried that, still the same.

1 like

Please or to participate in this conversation.