Firebase captcha check fails and prevents user from authenticating
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: https://firebase.google.com/docs/auth/android/phone-auth#enable-app-verification
Solution 3
Step 1: Select a Project.
Step 2 : Enable Android Device Verification
Use below the link to Enable Android Device Verification.
https://console.cloud.google.com/apis/library/androidcheck.googleapis.com
abhishek
Updated on July 30, 2022Comments
-
abhishek almost 2 years
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
otpVerification.kt
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?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_otp_verification) 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(R.id.otp_form_feedback) mOtpProgress = findViewById(R.id.otp_progress_bar) mOtpText = findViewById(R.id.otp_text_view) auth=Firebase.auth database = FirebaseDatabase.getInstance().reference mVerifyBtn = findViewById(R.id.verify_btn) 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) signInWithPhoneAuthCredential(credential) } }) } private fun signInWithPhoneAuthCredential(credential: PhoneAuthCredential) { auth?.signInWithCredential(credential) ?.addOnCompleteListener(this, OnCompleteListener<AuthResult?> { task -> if (task.isSuccessful) { createAccount(email,password) mCurrentUser= auth.currentUser!! Prefs.put(this, mCurrentUser) Log.d("user",mCurrentUser.toString()) sendUserToHome() 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, MainActivity::class.java) intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK startActivity(intent) finish() } 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) .show() sendEmailVerification() val intent = Intent(this, MainActivity::class.java) intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP startActivity(intent) Log.d("Delete", "deleting activity signup") finish() } else { // If sign in fails, display a message to the user. Log.w("TAG", "createUserWithEmail:failure", task.exception) Toast.makeText( baseContext, "Authentication failed.", Toast.LENGTH_SHORT ).show() // updateUI(null) } // [START_EXCLUDE] // [END_EXCLUDE] } // [END create_user_with_email] createUSer() } private fun sendEmailVerification() { // Send verification email // [START send_email_verification] val user = auth.currentUser!! user.sendEmailVerification() .addOnCompleteListener(this) { task -> if (task.isSuccessful) { Toast.makeText(baseContext, "Verification email sent to ${user.email} ", Toast.LENGTH_SHORT).show() Log.d("TAG", "sendEmailVerification") } else { Log.d("TAG", "sendEmailVerification", task.exception) Toast.makeText(baseContext, "Failed to send verification email.", Toast.LENGTH_SHORT).show() } // [END_EXCLUDE] } // [END send_email_verification] } fun createUSer(){ database.child(USER_REF).child(uname).child("email").setValue(email) Log.d("CREATED","create user"+uname) } }
logcat
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" } ] } } 400 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: com.google.firebase.auth.FirebaseAuthException: 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.
-
abhishek over 3 yearsThank You for your effort but I already got the answer and marked it correct