Firebase Phone OTP - Android

Android has added Play Integrity API you can read more here. For OTP to work you need to do the following:

Enable Play Integrity responses

To use the Play Integrity API, you must enable Play Integrity API responses by linking your app to a Google Cloud project. Then follow the instructions to integrate the API into your app.

Apps on Google Play

In the Play Console, navigate to the Release section of the left menu. Go to Setup > App integrity. Select the Integrity API tab to get started.

Apps exclusively distributed outside Google Play

You can enable Play Integrity API responses for your app without using the Google Play Console. To do so, complete these steps:

  1. Choose an existing project or create a new project from the Google Cloud Console.

  2. Go to APIs and services and select enable APIs and services.

  3. Search for Play Integrity API. Select it and then select Enable.

SHA Keys

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.

How to generate the app SHA1 and SHA256

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, Navigate to the android folder in the project in your terminal/cmd, Then type the following command below

//FOR WINDOWS
gradlew signingReport
//FOR MAC or Linux
.\gradlew signingReport

use ./gradlew signingReport or .\gradlew signingReport if in windows to get debug keys.

Release Keys

For release keys use Keystore explorer 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

SHA1 & SHA256 From google play console

NOTE: If you are using issues with firebase OTP, you might have to also add the SHA1 and SHA256 from google Play app signing section.

Last updated