The issue is related to your sessions, which is always a tricky problem to catch. In oAuth2 you can provide a state
parameter when sending the user to authenticate, it is then sent back with the user to your application once they have authenticated.
Socialite puts a random string into the session and this state
parameter and checks it contains the same value when the user returns.
See line 134 and 212. https://github.com/laravel/socialite/blob/e04ab0bb972662fc72708dfd4eef35200965cca1/src/Two/AbstractProvider.php#L134
Theres a few solutions to try...
First things first, are you able to login just using your username and password instead of the google oauth?
Check your config/session.php
domain is set correctly and that the https
option is only set to true
if you're running over HTTPS. If the https
option is enabled then sessions will only ever be set when the site is accessed via. https.
'domain' => 'example.com',
If you are using subdomains in your application prepend a .
to the start of your domain in your session config. This will allow the session to carry across to all subdomains.
'domain' => '.example.com',
When you get sent through to the google login you should see the state
parameter on the URL, check this state is also returned when going back to your application.
You could also try clearing your browser cookies and cache (or use an incognito window) this ensures theres no conflicts between your previous tests/existing cookies.
You may also try reinstalling your dependencies by removing your /vendor
folder and running composer install
again. This for me in the past has solved issues with sessions for unknown reasons.