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

juranir's avatar

Socialite error with Google: Missing required parameter: code

Hello :D

I'm trying to configure google authentication but I'm having a behavior that I'm not sure if it's ok. When I try to authenticate using a button that redirect user through Socialite (Socialite::driver('google')->redirect()) using stateless the process working well, but if I try to use Google button (like oneTap login) I have an exception:

throw new InvalidStateException (from laravel/socialite/src/Two/AbstractProvider.php)

After debugging a little bit, I notted the real error message is:

Client error: POST https://www.googleapis.com/oauth2/v4/token resulted in a 400 Bad Request response: { "error": "invalid_request", "error_description": "Missing required parameter: code" }

So I don't know if this behavior is supossed to be ok or if someone else already did it.

PS. I already configured the SESSION_DOMAIN

Env:

Laravel: 10

Socialite: 5.6.1

0 likes
1 reply
yusufhikam's avatar

Try running

php artisan route:clear,

php artisan cache:clear,

php artisan config:clear

After doing that, it worked for me.

Please or to participate in this conversation.