我在 Firebase 中使用电话身份验证。但是当我实现它时,它显示以下错误:
E/zzf: Problem retrieving SafetyNet Token: 7:
然后这个E/FirebaseAuth: [GetAuthDomainTask] Error getting project config. Failed with INVALID_CERT_HASH 400
这是我的完整代码
if(GoogleApiAvailability.getInstance()
.isGooglePlayServicesAvailable(this, 13000000) ==
ConnectionResult.SUCCESS){
byte[] nonce = generateNonce();
SafetyNet.getClient(this).attest(nonce, Names.SAFETY_NET_API)
.addOnSuccessListener(new OnSuccessListener<SafetyNetApi.AttestationResponse>() {
@Override
public void onSuccess(SafetyNetApi.AttestationResponse attestationResponse) {
Log.i("Success", "Safetynet Connected");
Log.i("Success Result" , attestationResponse.getJwsResult());
signIn(txtNumber.getText().toString(), attestationResponse.getJwsResult());
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(StartingActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
progressBar.setVisibility(View.GONE);
}
});
}
登录方式
private void signIn(String phoneNumber, String token){
PhoneAuthOptions options =
PhoneAuthOptions.newBuilder(mAuth)
.setPhoneNumber("+91" + txtNumber.getText().toString())
.setTimeout(60L, TimeUnit.SECONDS)
.setActivity(StartingActivity.this).setCallbacks(callbacks).build();
PhoneAuthProvider.verifyPhoneNumber(options);
}
我还在 firebase 中添加了 sha-1 和 sha-256。还添加 Android 设备检查 api 密钥。我是怎么做到的,请任何人帮助我。