# Email Sign In by Firebase

{% hint style="info" %}
To use Sign In, you will need to first create your own Firebase account and project
{% endhint %}

{% embed url="<https://youtu.be/M9XVdLU25fQ>" %}

## Getting Started

### Create your free [Firebase](https://firebase.google.com/) account and create a new project

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LApyfVvhR8odKR4YQF2%2F-LApyw3bvIOR5-JAB_w5%2FThunkable%20Documentation%20Exhibits%20\(70\).png?alt=media\&token=608404dd-88e1-4b12-882f-31c2d64ab94d)

### Enable Email / Password Sign in

In the Firebase console, navigate to Authentication and the tab "Sign-In Method". Enable Email/Password as shown below.

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LAn5wecEraNWaG7Ig2g%2F-LAn69LqKwm8IN8GZyqJ%2Ffirebase-%E2%9C%95-fig-4.png?generation=1524497165800299\&alt=media)

### Connect your Firebase Account with Thunkable

There are two properties that you need to retrieve from Firebase to connect it with Thunkable which are both retrievable from the Firebase console: `API key` and `database URL`

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LApxibD39rc9AEH2Eas%2F-LApyIjcnOtwD72IBTH2%2FThunkable%20Documentation%20Exhibits%20\(67\).png?alt=media\&token=d1690bef-ab7e-4f48-a2e4-396547cf92a3)

`API key` and `database URL`

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LApxibD39rc9AEH2Eas%2F-LApyLIkRV82bHzOpleV%2FThunkable%20Documentation%20Exhibits%20\(68\).png?alt=media\&token=f782472f-2630-45a0-8e75-17097a4e7aba)

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LApxibD39rc9AEH2Eas%2F-LApyNNWBRAZDpCzIvN4%2FThunkable%20Documentation%20Exhibits%20\(69\).png?alt=media\&token=cf756958-aa68-47b6-8e49-33ad60660789)

### (Optional) Modify the email template you send to verify your users' emails

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LAn5wecEraNWaG7Ig2g%2F-LAn69OX26OWFvWU9YAd%2Ffirebase-%E2%9C%95-fig-5.png?generation=1524497165955904\&alt=media)

## Using the Sign In Component in your App

Click on the Sign In drawer of blocks to access the Sign In blocks.

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MJWfrtwPxcJj1KnpqoW%2F-MJWgaewcQAcQvcp6nNZ%2Fsign-in.png?alt=media\&token=00dcd9ba-b3cf-4626-bf48-7258aa45c717)

## Sign up

The first step for users is to Sign Up with their email address and a password. They will be sent an email to verify the address that they provided.&#x20;

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MYdkZkonHxV532xBVnH%2F-MYdkyDRiN3_GIjVSX8j%2FScreen%20Shot%202021-04-19%20at%2011.53.48%20AM.png?alt=media\&token=fe28e26e-b901-403b-8f24-ba018594b70e)

| Event                           | Description                                                                                                                                                       |
| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Sign up ( `email`, `password)`) | Signs up a user for a new account. Returns an `error` if sign up is not successful. A common `error` is "The email address is already in use by another account." |

Here is an example of using this block:

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MYdkZkonHxV532xBVnH%2F-MYdlJ6-z3hsMybnvHJ2%2FScreen%20Shot%202021-04-19%20at%2011.55.16%20AM.png?alt=media\&token=35ca7a34-7771-4040-8664-8cd50f1fb7dc)

## Sign in

This block will sign a user in and return their user ID.

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MYdkZkonHxV532xBVnH%2F-MYdlhzeo9tNMtDmrQ1o%2FScreen%20Shot%202021-04-19%20at%2011.57.04%20AM.png?alt=media\&token=3756269d-2656-44f8-9a88-ef4e9abe761d)

| Name            | Data Type  | Data                                                              |
| --------------- | ---------- | ----------------------------------------------------------------- |
| error           | Text       | If error, returns error; else, returns `null`                     |
| userId          | Text       | Returns unique ID for each account                                |
| isEmailVerified | True/False | If email has been verified, returns `true`; else, returns `false` |

When the user's email and password have been stored locally, the following blocks can be used to sign the user in with these details automatically.

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MYdkZkonHxV532xBVnH%2F-MYdmcL0EM8Nfwy6MVRv%2FScreen%20Shot%202021-04-19%20at%2012.01.03%20PM.png?alt=media\&token=b8091257-d414-4028-9caf-69d4e334ecba)

## Sign Out

Signs the user out.

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MYdkZkonHxV532xBVnH%2F-MYdmkKjGqJlV526UNgN%2FScreen%20Shot%202021-04-19%20at%2012.01.33%20PM.png?alt=media\&token=d3ca7d89-6a40-4b88-9ef4-5a68f6701460)

## Reset Password

Send an email to the specified email address to reset their password

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-MYdkZkonHxV532xBVnH%2F-MYdmzLBjXgAzeuYOC_C%2FScreen%20Shot%202021-04-19%20at%2012.02.37%20PM.png?alt=media\&token=10f2396e-4e84-49ab-b535-1fad0cd4d81e)

## Manage User Access

On the Firebase console, navigate to the Users tab under Authentication and you'll find a dashboard where you can reset a user's password, disable and delete their accounts.

![](https://689802330-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAn5scXl2uqUJUOqkJo%2F-LAn5wecEraNWaG7Ig2g%2F-LAn69UwOJpXTThRSq3r%2Ffirebase-%E2%9C%95-fig-1.png?generation=1524497165853546\&alt=media)
