DarkShadow
DarkShadow

Reputation: 197

Getting an error in PhoneAuthCredential

what is the meaning of error "java.lang.IllegalArgumentException: Cannot create PhoneAuthCredential without either verificationProof, sessionInfo, ortemprary proof."

Upvotes: 0

Views: 4502

Answers (3)

Daniel Kabu Asare
Daniel Kabu Asare

Reputation: 288

It returns an exception so the aim should be to catch the exception it throws in the debug console. I do that by wrapping the portion of that code in a try catch and Toast it out for the user of the aim to see rather than the usual crash which isnt visible to the End Users.

Like this...

private void verifyCode(String code) {
    try {
        PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationId, code);
        signInWithCredential(credential);
    }catch (Exception e){
        Toast toast = Toast.makeText(getApplicationContext(), "Verification Code is wrong, try again", Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER,0,0);
        toast.show();
    }

}

Upvotes: 1

Mufaro Gomera
Mufaro Gomera

Reputation: 1

You must add your SHA1 key to your firebase app settings.

Upvotes: 0

Priyambad Singh
Priyambad Singh

Reputation: 11

Calls to PhoneAuthProvider.getCredential(...) return a PhoneAuthCredential object, which is defined as:

Wraps phone number and verification information for authentication purposes.

So getCredential() cannot return an error message. Instead it throws an exception if there is a problem with the verification/credential information you provided.

Upvotes: 0

Related Questions