I'm getting error for phone authentication. I received OTP successfully, but after I share my project with my team member with GitHub, I'm getting this errors.
I also I added MY SHA 1 & SHA 256 in my new firebase console. I also added dependencies, but still I get this error.
I also want to inform that after transfer my project with GitHub, I make new firebase account and add SHA 1 & SHA 256 in this project
Logcat:
03-16 16:19:40.001 8163-8163/com.roundtripride E/zzf: Problem retrieving SafetyNet Token: 7:
03-16 16:19:40.679 8163-8235/com.roundtripride E/FirebaseAuth: [GetAuthDomainTask] Error getting project config. Failed with INVALID_CERT_HASH 400
03-16 16:19:40.713 8163-8163/com.roundtripride E/zzf: Failed to get reCAPTCHA token with error [There was an error while trying to get your package certificate hash.]- calling backend without app verification
03-16 16:19:41.202 8163-8201/com.roundtripride E/FirebaseAuth: [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17093 null
03-16 16:19:41.202 8163-8163/com.roundtripride E/Tag: onVerificationFailed : 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.
03-16 16:19:41.202 8163-8163/com.roundtripride E/Tag: onVerificationFailed : 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.
03-16 16:19:41.202 8163-8163/com.roundtripride E/Tag: onVerificationFailed : 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.
Dependencies:
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.google.android.libraries.places:places:2.4.0'
implementation platform('com.google.firebase:firebase-bom:26.7.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-auth:20.0.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
implementation 'com.intuit.sdp:sdp-android:1.0.6'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'com.amitshekhar.android:jackson-android-networking:1.0.2'
implementation 'com.github.prolificinteractive:material-calendarview:1.6.0'
implementation 'androidx.browser:browser:1.3.0'
implementation 'com.google.firebase:firebase-messaging'
implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
}
Code:
public class OTPVerifyActivity extends BaseActivity implements View.OnClickListener {
Context context;
private FirebaseAuth mAuth;
private String mVerificationId;
String idToken = "", mobile;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_otp_verify);
Utility.setLoginStatusColor(this);
context = this;
txt_finish = findViewById(R.id.txt_finish);
edt_1 = findViewById(R.id.edt_1);
mAuth = FirebaseAuth.getInstance();
mobile = getIntent().getStringExtra("mobile");
sendVerificationCode();
txt_finish.setOnClickListener(this);
}
@Override
public void onClick(View view) {
if (view == txt_finish) {
Utility.hideSoftKeyboard(edt_1, context);
if (edt_1.getText().toString().equals("")) {
Utility.errDialog("Please enter OTP", context);
} else {
verifyVerificationCode(edt_1.getText().toString().trim());
}
}
}
private void sendVerificationCode() {
PhoneAuthOptions options =
PhoneAuthOptions.newBuilder(mAuth)
.setPhoneNumber("+91" + mobile) // Phone number to verify
.setTimeout(30L, TimeUnit.SECONDS) // Timeout and unit
.setActivity(this) // Activity (for callback binding)
.setCallbacks(mCallbacks) // OnVerificationStateChangedCallbacks
.build();
PhoneAuthProvider.verifyPhoneNumber(options);
}
private PhoneAuthProvider.OnVerificationStateChangedCallbacks mCallbacks = new PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@Override
public void onVerificationCompleted(PhoneAuthCredential phoneAuthCredential) {
Log.e("Tag", "get Data : " + phoneAuthCredential.getSmsCode());
Utility.dismissProgressDialog(pd);
String code = phoneAuthCredential.getSmsCode();
if (code != null) {
edt_1.setText(code);
verifyVerificationCode(code);
}
}
@Override
public void onVerificationFailed(FirebaseException e) {
Utility.dismissProgressDialog(pd);
Log.e("Tag", "onVerificationFailed : " + e.getMessage());
Log.e("Tag", "onVerificationFailed : " + e.getLocalizedMessage());
Log.e("Tag", "onVerificationFailed : " + e.toString());
Utility.errDialog(e.getMessage(), context);
}
@Override
public void onCodeSent(String s, PhoneAuthProvider.ForceResendingToken forceResendingToken) {
super.onCodeSent(s, forceResendingToken);
mVerificationId = s;
Utility.dismissProgressDialog(pd);
}
};
private void verifyVerificationCode(String code) {
//Log.e("Tag","Verify code : "+code);
pd = Utility.showProgressDialog(context);
try {
PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId, code);
signInWithPhoneAuthCredential(credential);
} catch (Exception e) {
Log.e("Tag", "PhoneAuthCredential Exception " + e.getMessage());
}
}
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
mAuth.signInWithCredential(credential)
.addOnCompleteListener(OTPVerifyActivity.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
FirebaseUser user = mAuth.getCurrentUser();
user.getIdToken(true)
.addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
public void onComplete(@NonNull Task<GetTokenResult> task) {
if (task.isSuccessful()) {
idToken = task.getResult().getToken();
Utility.dismissProgressDialog(pd);
Log.e("Tag", "Success OTP " + isDriver);
MyPreference.setPreferenceValue(context,"isLogin","true");
}
}
});
} else {
Utility.dismissProgressDialog(pd);
//verification unsuccessful.. display an error message
String message = "Something is wrong, we will fix it soon...";
if (task.getException() instanceof FirebaseAuthInvalidCredentialsException) {
message = "Invalid code entered...";
}
Log.e("Tag", message);
Utility.errDialog(message, context);
}
}
});
}
}
Remove your debug SHA-1 and SHA-256 from your old firebase account.
Open android studio and click on gradle in right corner > click your project > select app > select tasks > select android > click on signing report > copy our SHA1 and SHA-256 from there.
Add SHA1 and SHA-256 in your new firebase account.(if you are building apk from 2 system add both system's SHA1 and SHA-256).
You need to make sure that you enabled PHONE AUTHENTICATION in Firebase console => Authentication => Sign-in Methods.
Add dependency in build.gradle(:app)
implementation 'androidx.browser:browser:1.3.0'
Go to google cloud console, select your project.
Click on navigation menu and select APis & services and then select Dashboard.
Click on enable api and services and enable api " Android Device Verification".
Download and replace the latest google-services.json file in your project.
implementation 'androidx.browser:browser:1.3.0'
please add this dependency then check sha1 and sha256 one more time then try it
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.