# Log the User In with Google

This action logs the user in with authentication from a Google account.

***

## <mark style="color:blue;">Firebase Console Configuration</mark>

Go to the [Firebase Console](https://console.firebase.google.com/) of you project, and them to the Authentication service. On it, you must select the tab "Sign-in method".

Link: <https://console.firebase.google.com/u/0/project/YOUR_PROJECT_ID/authentication/providers>.

If you click on "Add a new provider", will be able to choose from various authentication methods.

<div align="left"><figure><img src="https://284736847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiWu3FezEjWxrPbkf8zIP%2Fuploads%2FLqVqnPTKqQTTmYjygpG2%2Fimage.png?alt=media&#x26;token=78f3ce6c-b097-4d0a-9278-01c87d29e8e6" alt=""><figcaption></figcaption></figure></div>

Right now, the plugin supports only Email/Password, Google, Facebook and Github methods.

When you select the Google method, it you ask you to select a public-facing name for the app and a support email address for the users to contact.&#x20;

{% hint style="info" %}
Tip: You can add user's or business emails to your apps "Users and permissions" settings, and those emails will become available as suport emails.
{% endhint %}

<div align="left"><figure><img src="https://284736847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiWu3FezEjWxrPbkf8zIP%2Fuploads%2F3AxsxADYEkrWiB4X3GKA%2Fimage.png?alt=media&#x26;token=64e1f66a-a22b-4a35-829c-3d70d04e6c6c" alt=""><figcaption></figcaption></figure></div>

After filling the info and clicking "Save", Firebase will configure everything for you on Google Cloud to allow for Google authentication.

{% hint style="warning" %}
Remember to allow you apps domain on the Authentication settings (see below)
{% endhint %}

<figure><img src="https://284736847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiWu3FezEjWxrPbkf8zIP%2Fuploads%2FSXIqwROIAhGwLhrKNVN9%2Fimage.png?alt=media&#x26;token=23119e1e-bb39-4c4a-be7e-e8e06ae64a13" alt=""><figcaption></figcaption></figure>

***

## <mark style="color:blue;">Inputs and Settings</mark>

<div align="left"><figure><img src="https://284736847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiWu3FezEjWxrPbkf8zIP%2Fuploads%2FZjkqm5LIpSC3CEUlt9qP%2Fimage.png?alt=media&#x26;token=86a64a56-a1f4-47b0-ac0f-ad0a4f3e7955" alt=""><figcaption></figcaption></figure></div>

### Trigger ID (optional)

This will link the action with a [Action Listener](https://estare.gitbook.io/firebase-auth-firestore-and-storage-plugin/plugin-elements/firebase-action-listener) of the same ID.&#x20;

If left blank, all listener on the page with blank ID's will be triggered at the same time, so we suggest to always define a Trigger ID.

When the function finishes running, it will trigger the [User Signed Up](https://estare.gitbook.io/firebase-auth-firestore-storage-plugin/plugin-elements/firebase-action-listener#user-signed-up) event, storing the [New User ID](https://estare.gitbook.io/firebase-auth-firestore-storage-plugin/plugin-elements/firebase-action-listener#new-user-id) and [New User Email](https://estare.gitbook.io/firebase-auth-firestore-storage-plugin/plugin-elements/firebase-action-listener#new-user-email) on the listener's states.

### Copy profile data into firestore collection

If you check this option, the user's profile data will be stored not only on the user, from the Firebase Authentication service, but also on the user's document.

If is recommended to left it checked, since it gives more flexibility while accessing this information, as well as utilizing it on queries and filters for users.

### Other User Data

<div align="left"><figure><img src="https://284736847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiWu3FezEjWxrPbkf8zIP%2Fuploads%2FFKkmWqyxxhmZozCHqSWG%2Fimage.png?alt=media&#x26;token=e1720196-6048-43ef-9838-a0523735aed5" alt=""><figcaption></figcaption></figure></div>

### Users Collection

The name or ID of the collection where user's should be stored in. A document will be created with the same ID of the newly created user account.

### Fields

Since a new document is being created, you can store data in it the same way it is done to any [new document](https://estare.gitbook.io/firebase-auth-firestore-and-storage-plugin/plugin-front-end-actions/firestore/create-a-new-document).

When you create a document on Firestore, you must inform which fields and which content each will have on it's structure, in JSON format. This input allows you to set as many fields as you want.

For each field you must specify the "key" and the "value" that will be stored. For instance, you might want to store a "status" for the new user, of "active", to control access to your app. You'd need to define the "key" = "status" and the "value" = "active".

<div align="left"><figure><img src="https://284736847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiWu3FezEjWxrPbkf8zIP%2Fuploads%2Fw3reRG7zNotV4aO95Hlz%2Fimage.png?alt=media&#x26;token=6be69c81-95bc-4ff8-82ea-1ef980f317e3" alt=""><figcaption></figcaption></figure></div>

### Field Types

For each key/value pair you define and provide a value on the Fields list, you must provide the same key, but with the type of the value, on the Field Types input. That allows the plugin to turn the texts being fed into the plugin into corresponding values on the JSON structure sent to Firestore.

If the number of Fields and Field Types don't match, the action will result in an error.

<div align="left"><figure><img src="https://284736847-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FiWu3FezEjWxrPbkf8zIP%2Fuploads%2FkRGFxb7V0mNH7he6aaqh%2Fimage.png?alt=media&#x26;token=c2e3d516-66d0-4701-849e-e693824f3fae" alt=""><figcaption></figcaption></figure></div>

See the [field types table](https://estare.gitbook.io/firebase-auth-firestore-and-storage-plugin/plugin-front-end-actions/field-types-table) to see which types are currently supported by the plugin and how to define them.

***

## <mark style="color:blue;">Triggered events</mark>

Those events are triggered by an [Action Listener](https://estare.gitbook.io/firebase-auth-firestore-and-storage-plugin/plugin-elements/firebase-action-listener) with the same ID as the [Trigger ID](#trigger-id-optional) provided on the action.

* User Signed Up (if the action was successful and it's the first time the user logged in)
* User Logged In (if the action was successful and it's not the first time the user logged in)
* Error in Action (if an error occurs)

***

## <mark style="color:blue;">Stored values on the listener</mark>

### User ID

The ID of the user and document created by the action.

### User Email

The email of the user account created by the action.

### Error Message

If an error occurs, you can check its details on this state on the action listener.
