# Firebase Phone OTP/ SHA1

### Enable phone authentication on firebase first.

1. Click on authentication
2. Click on Sign-in method tab
3. click on phone then enable it
4. on the sign-in method tab, scroll to the Authorized domains
5. Add your backend domain. This is so firebase can allow request from your server.

### OTP

Android has added **SafetyNet** you can read more [here](https://developer.android.com/training/safetynet). For OTP to work you need to do the following:

* enable the **Android Device verification api** on the google cloud console. Follow the link [here](https://console.cloud.google.com/apis/library/androidcheck.googleapis.com) to enable it.

![](https://1451848172-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQBree38dhIotXdn4oz%2F-Macctk6go5H4z5177ur%2F-Macd7tiKrstDmvq9k45%2Fimage.png?alt=media\&token=34eeee28-5664-4244-a367-b1fa95c13e69)

* If you haven't yet specified your app's SHA-256 fingerprint, do so from the Settings Page of the Firebase console. For more info read [details here.](https://firebase.google.com/docs/auth/android/phone-auth)

![](https://1451848172-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MQBree38dhIotXdn4oz%2F-Macctk6go5H4z5177ur%2F-MacdCXtsQkww9aEqUz4%2Fimage.png?alt=media\&token=4c94fb04-6a8c-4e15-b881-b15cf612b43f)

### How to generate the app SHA1 and SHA56

You need to configure firebase phone auth for phone otp verification to work, without this you would running into errors building the app.

To solve this error, you need to add both your keystore SHA1 and SHA56 as well as debug SHA1 and SHA256 to fireabse console.

That means two **SHA1** and two **SHA256**

For debug keys use <https://developers.google.com/android/guides/client-auth?authuser=1> to get the key, use `./gradlew signingReport` or `.\gradlew signingReport` if in windows to get debug keys.

For release keys use [Keystore explorer](https://keystore-explorer.org/) to see the SHA1 and SHA256.

If the issue persists after changing your **SHA1** and **SHA256** make sure the following:

1. Change the google-services.json file again.
2. Delete the app in settings and add a new one with the right SHA1


---

# 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/meetup/flutter-app/firebase-phone-otp-sha1.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.
