# Google Login

## Google Sign In <a href="#id-1834" id="id-1834"></a>

There are a few new steps you have to do in order to use **Google Sign In** in the foodie app. Without completing all these steps, if you try to use Google Sign In, the app will just crash. I will show you how to set up Google Sign In using **Firebase** from scratch.

## Setup Firebase project <a href="#d4bb" id="d4bb"></a>

If you already have a firebase project setup, you can ignore this section but if you haven't I will take you through the process of setting up the firebase project for your your app. You need to have a firebase project for the foodie app.&#x20;

To create a new Firebase project you will need to go [here](https://console.firebase.google.com/).

1. Click on “***Add project***” to create a new project.

<div align="left"><img src="https://2000810127-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MBZ05WbSufXsgpTD0UB%2F-MH_j04i4mwFOqixIFSJ%2F-MH_lNA-H4c5weC7HIj-%2F1_OdkcPjoktutZQVKShV2owQ.png?alt=media&#x26;token=c488cb28-592b-4347-8876-bba31bc9c15f" alt=""></div>

&#x20; 2\. Now, you have to enter a “***Project name***” and check the two checkboxes below. Then, click on “***Create project***”.

![](https://2000810127-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MBZ05WbSufXsgpTD0UB%2F-MH_j04i4mwFOqixIFSJ%2F-MH_m57U6ZXkbIGi46YB%2F1_QRs5KwGQI1KN51mwq8hBAw.png?alt=media\&token=74f06fd9-cae8-4fcf-baf6-990e4ed4e31e)

&#x20;  3\. Now, wait for the creation to complete and click on “***Continue***”.

&#x20;  4\. This will lead you to the “***Project Overview***”. From here you will be able to add **Firebase** to your **Flutter** project.

## Firebase Project setup <a href="#d360" id="d360"></a>

We have already setup Firebase for you on the Foodie project, but you would need to change some of the configuration to your needly created firebase project.

Here is a link to the official firebase documentation on how to link firebase to both android and iOS

Android Link: <https://firebase.google.com/docs/flutter/setup?platform=android>

iOS Link: <https://firebase.google.com/docs/flutter/setup?platform=ios>

## **Firebase Authentication Setup**

After you have successfully setup the project with  firebase, you will need to enable authentication on firebase.&#x20;

On the firebase console,&#x20;

1. go to **Authentication Page** → **Users** tab and click on “***Set up sign-in method***”. <img src="https://2000810127-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MBZ05WbSufXsgpTD0UB%2F-MH_mWOujOP6kY-gs8qC%2F-MH_oHlN6G-htzre15h3%2F1_zYKM8uevDF7Zo6OoikaJNQ.png?alt=media&#x26;token=f61229be-847b-4d60-bee1-527601143b6d" alt="" data-size="original">&#x20;
2. In the “***sign-in providers***” page, edit ***Google*** sign-in.
3. Here, you have to enter the **project name** and **support email**. And “***Enable***” this by clicking the toggle on the top-right corner. Then, click on **Save**.
4. &#x20;<img src="https://2000810127-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MBZ05WbSufXsgpTD0UB%2F-MH_mWOujOP6kY-gs8qC%2F-MH_orUIWSP3txdo0LtV%2F1_OZ3iV8HZtcjvidhdTz5Fpg.png?alt=media&#x26;token=84799626-55ef-4374-a60a-ea2ffde323ba" alt="" data-size="original">&#x20;
5. So, now the google sign in setup is complete. Run the app on the device again.

## Firebase ***OAuth consent screen***

> But to your surprise, you will again see that the same Exception occurs. Now, this gets interesting, this occurs because you have not filled up the OAuth consent form. This is the new change in Firebase that I was talking about from the beginning and it is just driving developers crazy because I have not found them properly documented anywhere.

Let’s see how to fix this issue.

1. First of all, go to this page [***here***](https://console.developers.google.com/apis/credentials/consent).
2. Make sure you are signed in with the **same account** with which you have created the **Firebase project**.
3. Also, make sure that on the top-left corner, your project is selected for which you are filling this consent.
4. &#x20;<img src="https://2000810127-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MBZ05WbSufXsgpTD0UB%2F-MH_qB9-PScXxMYoVp2e%2F-MH_qGHCx6hvshyn1v8v%2F1_kocIXf7WOyXevCZBPSFIUg.png?alt=media&#x26;token=e3fda9ae-e7ac-463f-ae7d-2c6c8c10cc74" alt="" data-size="original">&#x20;
5. &#x20;Go to ***Credentials → OAuth consent screen*** tab and start filling the form.
6. Enter “***Application name***”, “***Application logo***” & “***Support email***”.

   > In the **Application Logo**, you can just enter any image if you are not making this for **production**, otherwise, enter the real **app icon** that you are using for your application.
7. Then, scroll down and fill the “***Application Homepage link***”, “***Application Privacy Policy link***” and “***Application Terms of Services link***”. In all these places, you have to enter the same link starting with `http://` then your app domain name which I have marked with ***green*** below.
8. <img src="https://2000810127-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MBZ05WbSufXsgpTD0UB%2F-MH_qB9-PScXxMYoVp2e%2F-MH_qjeAHoe1B9H7ciMa%2F1_m3l7TtDq0ymLdGGKtdticA.png?alt=media&#x26;token=a877deab-079d-4920-b68a-974f01f52bb1" alt="" data-size="original">&#x20;
9. Click on ***Save***.

So, this completes the whole setup process for “***Sign in with Google***” using ***Firebase*** for ***Android (iOS** needs extra configuratio&#x6E;**)***. Now, again run the app on your device and attempt google sign in. You will find that it suddenly started working without any exception.

## **Firebase iOS Extra step**

Open this [***google\_sign\_in***](https://pub.dev/packages/google_sign_in#ios-integration) flutter package page. Inside **iOS integration** you will find a code snippet. Just copy & paste it inside the **Info.plist** file and save it, like this:<br>

![](https://2000810127-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MBZ05WbSufXsgpTD0UB%2F-MH_qB9-PScXxMYoVp2e%2F-MH_rYF9_5g4czFthD3G%2Fimage.png?alt=media\&token=40534812-ffa0-4abb-bfd8-5d09adc4df91)

Here, you will see that there is a **TODO** written to replace the value within the ***string*** tag with “***REVERSED\_CLIENT\_ID***”. You will find the ***REVERSED\_CLIENT\_ID*** in the file “***GoogleService-Info.plist***”.

![](https://2000810127-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MBZ05WbSufXsgpTD0UB%2F-MH_qB9-PScXxMYoVp2e%2F-MH_rrDF3bczvh3X7x2X%2Fimage.png?alt=media\&token=94cd209f-8f73-4cb4-a114-7d7a6208ae9d)

So finally, this completes the whole setup process for “***Sign in with Google***” using ***Firebase*** for ***both Android and iOS***. Just follow these above steps properly and you should get past the setup pretty quickly.

## **Still having issues?**

Here is a link to a medium blog post about setting up the google sign in : <https://medium.com/flutter-community/flutter-implementing-google-sign-in-71888bca24ed>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://edentech.gitbook.io/foodie/social-login/google-login.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
