Flutter – Social Authentication – Google

Hi Friends,

Hope you are all well. This post is a sequel to my previous post on flutter authentication. In this post let’s talk about social authentication; i.e., authenticating users into your application with a third-party authentication provider like Google, Facebook or Twitter.

To learn the basics of flutter get my course – Click here.

Other flutter courses – here. (Affiliate Link)

Let’s begin.

A screencast of this post

Now let’s continue from where we left off.

(If you don’t have the code, kindly refer to my previous post here)

First let’s start with installing the dependencies.

Open up pubspec.yaml file and add the below dependency.

Alright, now open the firebase console and enable Google Sign-in provider.


Wait, there’s more to do. Open up the project settings and add we need to add a SHA1 fingerprint. If you don’t have one use the below command to generate it

(Enter this command in a terminal and copy the SHA1 key it generates and paste it as shown below)


Alright, that’s it for the configs. Let’s move on.

(If you have any doubt in the configuration, kindly watch the video once, I have shown how to do it step-by-step)

Open up Login Page and add another button as shown below.


That’s about it.

Now look at this piece of code.

This is where the actual sign-in happens. When we use google plugin to sign in we get a key with contains an idToken and an accessToken. We use this to authenticate the user into our flutter app (which uses the firebase authentication system for managing users). After authenticating the user we would need to redirect him to the dashboard page as well.

That’s it. Now run the app and you would see the below screen.


Try tapping on the Login with Google Button.

You would get signed in (An overlay would appear if you are using more than one google account in the same device)


Now open up your list of users in your firebase console. You would see that this user has been added into our system as well.


That’s it.

Hope this post helped you guys. If you found this helpful, kindly share it with someone and help them too.

Donate to keep this site alive – here.

(If you want to donate but can’t, it’s fine just subscribe to my youtube channel).

Join our flutter community – here.

Thanks for reading. Peace..

Liked it? Take a second to support admin on Patreon!