Current Stack
- Flutter for Android
- google_sign_in plugin for social network integration
- Laravel 12 for backend
- Socialite for Social Network integration
We want to enable users to sign up/in on our Android application using their Google account with the current setup that we have.
The plan is to have the Flutter app allow the user to sign up/in to our platform using their Google account. Then pass a reference to this user to our backend, have the backend re validate the user for security purpose and create/update a user in our database so that we’ll be able to recognized them later on even if they switched devices. Later on we would also want to enable other services for users to use to log in like Facebook.
To get this to work here’s what we did :
Flutter (frontend)
- Install google_sign_in plugin.
- Follow the their instruction to enable google sign in. This includes creating OAuth2 credentials. In our case we had to create 2 OAuth2 Clients: a web application and an android application, setting the hash for the android application amother other things.
- Once that is set up, you move to calling GoogleSignIn.instance.authenticate() in your application to start the authentication process. (you’ll need to initialize the plugin first, just follow their instructions)
- After authentication you will get a GoogleSignInAccount object from the GoogleSignInAuthenticationEvent event object. This should contain an authentication.idToken property. So if you’ve assigned the GoogleSignInAccont to a “user” variable, you can access this through user.authentication.idToken. Pass this idToken to laravel for further authentication and user details fetching from the server.
- For Laravel we’re using Socialite to make communication with third party sign in providers easy. In Google’s case we would use the idToken provided to fetch the user’s information via Laravel and at the same time verify the authentication before creating or logging in the user.
- From there we would just create a new user token for the user to persist their session from the flutter app.
Logging the user this way helps us maintain the user’s information even if they switch device.
There’s probably a better/cleaner solution but for us this works pretty well. We will be applying the same process for Facebook log in and see how it goes.
I hope this provide some insight on how we can implement Google sign in via Flutter and Laravel stack.
Cheers!

