Faslur Rajah
Faslur Rajah

Reputation: 1005

Firebase phone authentication is not working on Android real device

I've been trying to achieve phone auth using Firebase authentication. It's working with an android emulator. I used a test number and a real number in the emulator. Both works. But only the test number is working with a real device and throwing this exception for other numbers

Error is:[firebase_auth/missing-client-identifier] This request is missing a valid app identifier, 
 meaning that neither SafetyNet checks nor reCAPTCHA checks succeeded. 
 Please try again, or check the logcat for more details.

I setup SHA key in firebase also.

Upvotes: 45

Views: 63746

Answers (12)

Sourav Paul
Sourav Paul

Reputation: 11

For Android, Firebase requires you to add your app's SHA-1 and SHA-256 keys to the Firebase console. You can get these keys by running the following command in your project directory:

  1. cd android
  2. ./gradlew signingReport

Upvotes: 1

Jonah Sebright
Jonah Sebright

Reputation: 1

I added the debug SHA-1 and SHA-256 of the debug keystore by android studio to the firebase project (general settings), as explained here: https://developer.android.com/studio/publish/app-signing#debug-mode.

Upvotes: 0

Mian Aamir Shehzad
Mian Aamir Shehzad

Reputation: 198

Actually, two of my apps had the same OAuth2 client IDs which were creating the issue for Google Firebase Authentication to send the SMS OTP. How I solved this issue is mentioned as:

  1. Opened my project in the Google Cloud Platform dashboard.
  2. Moved to Credential Section
  3. Find the project which has the same key conflicting your own project under OAuth 2.0 Client IDs. Click to open it.
  4. Remove the IDs
  5. Restart your project and it's Done!

You can find the official help here.

Feel free is you have any issues on this topic. Thanks

Upvotes: 0

Guray Meric
Guray Meric

Reputation: 41

I removed my phone number from phone number for testing on firebase and it was worked for me when working on real device not emulator.

Upvotes: 0

Satish Singh
Satish Singh

Reputation: 81

This was worked for me :- If your app is published on the play store, Copy App signing key certificate from the Google Play console (Release > Setup > App Integrity page). Insert your signing key to your Firebase Console(Project settings Page).

Follow this link - https://developers.google.com/android/guides/client-auth

Upvotes: 0

Ilham Safeek
Ilham Safeek

Reputation: 287

SafetyNet is newly developed feature for android. But solved the issue without doing any changes in the App.

Following steps helped me to solve.

Release Version

  1. Google Signs the Appbundle when you upload. So, Find and copy the SHA1 key of the app signed by google. Google Play Console - App Signing Key

enter image description here

  1. Navigate to your project -> Project Settings in Firebase Console and add SHA1 key by clicking on Add fingureprint. enter image description here

Debug version

  1. Navigate to android directory of your project with following command with Terminal.

cd android

  1. Generate app signingReport and copy the SHA1 key

gradlew signingReport

on Mac :

./gradlew signingReport

enter image description here

  1. Add the SHA1 key in firebase app.

Upvotes: 20

Armar
Armar

Reputation: 289

Android has added SafetyNet you can read more here. But what you have to do is

1. enable the Android Device verification api here. and

2. 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.

Upvotes: 6

Khaledonian
Khaledonian

Reputation: 2203

There are two ways Firebase Authentication accomplishes this:

SafetyNet: If a user has a device with Google Play Services installed, and Firebase Authentication can verify the device as legitimate with Android SafetyNet, phone number sign-in can proceed.

or

reCAPTCHA verification: In the event that SafetyNet cannot be used, such as when the user does not have Google Play Services support, or when testing your app on an emulator.

So your solution is either one of two

  • Retest on a real device

  • Add reCAPTCHA verification functionality to your app so you can proceed with your emulator.

Upvotes: 1

Vela
Vela

Reputation: 97

I have fixed this error. In my case I added two android projects with same SHA-1 in single firebase project. Once I removed one project from firebase project. Now it is working for me.

Upvotes: 3

Muhammad Kashif
Muhammad Kashif

Reputation: 331

I resolved my issue by removing by old android studio sha-1 and sha-256 keys from firebase and adding a new one from the latest android studio.

Upvotes: 4

Hadi Pawar
Hadi Pawar

Reputation: 1126

I found this after much searching and should work for you or anyone else who stumbles here:

Put this line inside app/build.gradle under dependencies

implementation "androidx.browser:browser:1.2.0"

It is because its do reCAPTCHA verification and opens up browser.

Upvotes: 1

Ayush Surana
Ayush Surana

Reputation: 1926

I am guessing you have not enabled the Device Check API. All you need to do is enable the Device Check API on the cloud platform.

I think after some updates they have made this change that for Safety Net you need SH1 Authentication along with enabling Device Check API.

You can follow the Steps as mentioned here.

Once you enable the device check api. Restart your application. It should work like a charm.

Do lemme know if you need further steps.

Upvotes: 36

Related Questions