android - Firebase captcha check fails and prevents user from authenticating

android - Firebase captcha check fails and prevents user from authenticating

Nandita Maud Author: Nandita Maud Date: 2022-10-05
android - Firebase captcha check fails and prevents user from authenticating

All you need to know about android - Firebase captcha check fails and prevents user from authenticating , in addintion to android - Firebase : How to Check Count of Users on a Specific App Version from Firebase Console , android - Send an email to all the users on Firebase from Authentication list , android - Check if onStop is called from user interaction, or screen dimming , android - How to extract all the user's username who are online from firebase database.

  1. android - Firebase captcha check fails and prevents user from authenticating
  2. Question:

    I dont have idea why this error pop up . When I run the app on other device the app goes well but when I face issue on other device . Also I have issue while I am accessing firebase via wifi . I have contacted firebase support they say in INDIA they are facing issue with server and isp


    const val USER_REF:String="user"
    class OtpVerification : AppCompatActivity() {
    lateinit var  auth: FirebaseAuth
    private var mAuthVerificationId: String? = null
    private var mOtpText: EditText? = null
    private var mVerifyBtn: Button? = null
    private var mOtpProgress: ProgressBar? = null
    private var mOtpFeedback: TextView? = null
    lateinit var email:String
    lateinit var password: String
    private lateinit var database: DatabaseReference
    lateinit  var uname:String
    lateinit  var mCurrentUser: FirebaseUser
    override fun onCreate(savedInstanceState: Bundle?) {
        mAuthVerificationId = intent.getStringExtra("AuthCredentials")
        Log.d("AuthCredentials", mAuthVerificationId.toString())
        email= intent.getStringExtra("email").toString()
        password= intent.getStringExtra("password").toString()
        uname= intent.getStringExtra("name").toString()
        mOtpFeedback = findViewById(
        mOtpProgress = findViewById(
        mOtpText = findViewById(
        database = FirebaseDatabase.getInstance().reference
        mVerifyBtn = findViewById(
        mVerifyBtn?.setOnClickListener(View.OnClickListener {
            val otp = mOtpText?.text.toString()
            if (otp.isEmpty()) {
                mOtpFeedback?.visibility = View.VISIBLE
                mOtpFeedback?.text = "Please fill in the form and try again."
            } else {
                mOtpProgress?.visibility = View.VISIBLE
                mVerifyBtn?.isEnabled = false
                val credential = PhoneAuthProvider.getCredential(mAuthVerificationId!!, otp)
      private fun signInWithPhoneAuthCredential(credential: PhoneAuthCredential) {
                        OnCompleteListener<AuthResult?> { task ->
                            if (task.isSuccessful) {
                                mCurrentUser= auth.currentUser!!
                                Prefs.put(this, mCurrentUser)
                                Log.d("TAG", "Task is succesful")
                                // ...
                            } else {
                                if (task.exception is FirebaseAuthInvalidCredentialsException) {
                                    // The verification code entered was invalid
                                    mOtpFeedback?.visibility = View.VISIBLE
                                    mOtpFeedback?.text = "There was an error verifying OTP"
                            mOtpProgress?.visibility = View.INVISIBLE
                            mVerifyBtn?.isEnabled = true
     fun sendUserToHome() {
        val intent = Intent(this,
        intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
    private fun createAccount(email: String, password: String) {
        Log.d("TAG", "createAccount:${email.toString()}")
        //Log.d("TAG", "validate form is ${validateForm().toString()}")
        // [START create_user_with_email]
        auth.createUserWithEmailAndPassword(email, password)
                .addOnCompleteListener(this) { task ->
                    if (task.isSuccessful) {
                        // Sign in success, update UI with the signed-in user's information
                        Log.d("TAG", "createUserWithEmail:success")
                        val user = auth.currentUser
                        Toast.makeText(baseContext, "Authentication Success $user", Toast.LENGTH_SHORT)
                        val intent = Intent(this,
                        intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
                        Log.d("Delete", "deleting activity signup")
                    } else {
                        // If sign in fails, display a message to the user.
                        Log.w("TAG", "createUserWithEmail:failure", task.exception)
                                baseContext, "Authentication failed.",
                        //                   updateUI(null)
                    // [START_EXCLUDE]
                    // [END_EXCLUDE]
        // [END create_user_with_email]
    private fun sendEmailVerification() {
               // Send verification email
        // [START send_email_verification]
        val user = auth.currentUser!!
                .addOnCompleteListener(this) { task ->
                    if (task.isSuccessful) {
                                "Verification email sent to ${} ",
                        Log.d("TAG", "sendEmailVerification")
                    } else {
                        Log.d("TAG", "sendEmailVerification", task.exception)
                                "Failed to send verification email.",
                    // [END_EXCLUDE]
        // [END send_email_verification]
    fun createUSer(){
        Log.d("CREATED","create user"+uname)


    2020-11-11 17:57:45.290 28364-28364/com.bva_valai_pada E/zza: Problem 
    retrieving SafetyNet Token: 7: 
    2020-11-11 17:57:45.358 28364-28364/com.bva_valai_pada W/ActivityThread: 
    handleWindowVisibility: no activity for token android.os.BinderProxy@5308a64
    2020-11-11 17:57:45.873 28364-30352/com.bva_valai_pada E/FirebaseAuth: 
    [GetAuthDomainTask] Error getting project config. Failed with {
      "error": {
        "code": 400,
        "message": "INVALID_CERT_HASH",
        "errors": [
            "message": "INVALID_CERT_HASH",
            "domain": "global",
            "reason": "invalid"
    2020-11-11 17:57:45.919 28364-28364/com.bva_valai_pada E/zza: Failed to get 
    reCAPTCHA token - calling backend without app verification
    2020-11-11 17:57:45.962 28364-28364/com.bva_valai_pada I/AssistStructure: 
    Flattened final assist data: 4392 bytes, containing 1 windows, 13 views
    2020-11-11 17:57:45.966 28364-28410/com.bva_valai_pada W/System: Ignoring 
    header X-Firebase-Locale because its value was null.
    2020-11-11 17:57:46.611 28364-28410/com.bva_valai_pada E/FirebaseAuth: 
    [SmsRetrieverHelper] SMS verification code request failed: unknown status 
    code: 17093 null
    2020-11-11 17:57:46.621 28364-28364/com.bva_valai_pada D/Exception: 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.

    Solution 1:

    Ah, it looks like you need to add a SHA-1 Certificate Hash to your application registration in the Firebase Console. I think you can find instructions to do that here

    Solution 2:

    Your problem related to SHA1 and SHA256 keys. You have to add them to authenticate your certs.

    • List item

    • Goto

      Firebase Console of your project Authentication Project Setting (From Setting button near Project Overview) Add fingerprint Add SHA-1 and SHA-256 values of your keystore. You can get keystores from gradle like this.

    ./gradlew signingReport

    Read this for more information:

    Solution 3:

    Step 1: Select a Project.

    Step 2 : Enable Android Device Verification

    Use below the link to Enable Android Device Verification.

    enter image description here

  3. android - Firebase : How to Check Count of Users on a Specific App Version from Firebase Console
  4. Question:

    I would like to know how to check count of Users on a specific app version from firebase console (30 day active). For Example, our mobile app has 5 versions/releases. Need the result as per following.

    Version       Count
    3.1.5        250021
    3.1.4         45332
    3.1.3          4452
    3.1.2            24
    3.1.1             0 

    -- Update

    I managed to get some information in latest updated version for firebase console where app version wise dashboard was available.

    Is it possible to get some specific app page field value for users running their app on any specific version e.g. 3.1.2 for past 30 days, 7 days and last day ??

    Solution 1:

    Firebase Analytic's console is severely limited in what it can do.

    Connect your Firebase account to google analytics and use "Reporting Beta" and you'll be able to build this exact report.

    Here is a screenshot showing the options I selected to put it together.

    enter image description here

  5. android - Send an email to all the users on Firebase from Authentication list
  6. Question:

    Is there a way for me to send an email to all the users that are in my Authentication list. I know that I can send email on the beginning (Email address verification) but this is not a case. I made a new update to an app and I want to send an email explaining what went wrong.

    Solution 1:

    I know this question is over two years old at this point, but for anyone new coming across this -

    Firebase now provides Extensions, one of which addresses this issue:

    This extension automatically generates cloud-functions which adds new users to a specified Mailchimp audience, and removes them if they delete their account.

    If you have existing users that you wish to add first, then use the approach to list all users emails via the Admin SDK that @Doug Stevenson outlined previously.

    Solution 2:

    Solution 3:

    Edit 26'th January 2022

    Firebase released an extension called Trigger Email Extension from Firebase that can help achieve what you want. To implement this extension please follow the steps that are explained in the following article:

    • How to install and use Trigger Email Extension from Firebase?

    Firebase does not provide a newsletter service. The only way you can send an email to a user is when you are verifying the email address within the authentication process. To achieve what you want, you need to get the list of the emails of your users and use a third-party app that allows you to send bulk emails but be aware of spam email regulations.

  7. android - Check if onStop is called from user interaction, or screen dimming
  8. Question:

    I have a media player that stops playing whenever the user closes the app, either by pressing the home button, using the back button or simply opening another app. To get this behavior, I added an onStop() to my main activity which tells my MediaPlayer(which is in a service) to stop playing music.

    However, I would like the music to keep playing whenever the screen gets dimmed, either by using the power button to turn the screen off, or just by the screen auto dimming.

    Right now the player also stops playing when the screen dims, meaning that the onStop() method also gets called then.

    How can I check if the onStop() gets called by the screen diming?

    I already applied a PARTIAL_WAKELOCK to my MediaPlayer object, which to the best of my knowledge, should make it possible for the player to keep running after the screen goes off.

    Do I need to add a partial wakelock to my main activity as well?

    Just applied a PARTIAL_WAKELOCK to both my main activity, as well as my media player. Right now, the screen doesn't turn off by itself anymore, and when the user presses the power button the music still stops.

    Obviously, this doesn't work as I thought it does.

    Is there any way of achieving the behavior I'm looking for?

    Solution 1:

    You can add

    private boolean stoppedByUser = false;

    field to your activity, set it to false in onStart(), to true in onBackPressed() and onUserLeaveHint() and check it's value in onStop() method.

  9. android - How to extract all the user's username who are online from firebase database.
  10. Question:

    I want to extract all the user's username (highlighted blue) who are online (highlighted red) from a firebase database to a list view.

    enter image description here

    Solution 1:

    Just tested this, and it works!

    FirebaseDatabase database = FirebaseDatabase.getInstance();
    DatabaseReference reference = database.getReference("drivers");
    Query query = reference.orderByChild("online").equalTo("true");
    query.addValueEventListener(new ValueEventListener() {
        public void onDataChange(DataSnapshot dataSnapshot) {
            Log.d(TAG, dataSnapshot.toString());
        public void onCancelled(DatabaseError databaseError) { }

    Solution 2:

    I found the answer to the question, thanks to A. Omar and Frank van Puffelen for the help:

        DatabaseReference ref = FirebaseDatabase.getInstance()
        ref.addValueEventListener(new ValueEventListener()
            public void onDataChange(DataSnapshot dataSnapshot) {
                for (DataSnapshot driverSnapshot: dataSnapshot.getChildren())
                    Log.d(TAG, driverSnapshot.getKey() + " - " + driverSnapshot.child("online").getValue().toString());
            public void onCancelled(FirebaseError firebaseError) {

    this will print only the online users like:

    2332424 - true