Firebaseui-android: Cannot create PhoneAuthCredential without either verificationProof, sessionInfo, ortemprary proof.

Created on 17 Jul 2018  ยท  36Comments  ยท  Source: firebase/FirebaseUI-Android

Step 1: Are you in the right place?

We received a lot of crash report on the latest version 4.1.0 regarding to phone verification. The detail report are here http://crashes.to/s/77f7c50782c

The same users used our old version which is built with version 4.0.1 worked fine.

Step 2: Describe your environment

  • Firebase/Play Services SDK version: 16.0.2
  • FirebaseUI version: 4.1.0

Step 3: Describe the problem:

App crashes during using phone number login using Firebase Auth

Observed Results:

Expected Results:

Phone login works

Relevant Code:

We use https://firebase.google.com/docs/auth/android/firebaseui

auth help-wanted bug

Most helpful comment

@SUPERCILEX thanks for jumping on this! If we didn't have bugs like this, what would Android development be anyway?

All 36 comments

@baole thanks for the comment! Just adding some info here for my own reference:
fabric

Oh, I got it. ๐Ÿคฆโ€โ™‚๏ธ Users will switch to their messaging app and don't have a lot of RAM available so it kills your app. Since we only store the verification ID in memory, it gets lost. Side note: the number of times we've added bugs like this, you'd think we would learn. Nope. ๐Ÿ˜‚๐Ÿ˜‰

@samtstern I'll submit a PR tomorrow. ๐Ÿ‘

@samtstern PS: Personal life has been super busy, hoping to become more active again in a month or so. ๐Ÿ˜Š

@samtstern @SUPERCILEX the issue can be reproduced by enable the "Don't keep activities" option in Developer options on your test device.

am having this problem too

@SUPERCILEX thanks for jumping on this! If we didn't have bugs like this, what would Android development be anyway?

If we didn't have bugs like this, what would Android development be anyway?

๐Ÿคฃ So true

Anyway, submitted #1393

Great. Thanks @SUPERCILEX for the fix.

@samtstern, do you have any plan for 4.2.0 release?

@baole no set plan right now, you can follow along on the milestone to see as things get cleared.

This was fixed and released in version 4.2.0

same problem

Me too

I'm also having this issue right now when using firebase.auth().currentUser.updatePhoneNumber(credential)

For those seeing this issue recently: what version of FirebaseUI are you using? Can you provide logs of the failure?

using this dependency: com.firebaseui:firebase-ui-auth:4.3.1

and got this crash

Fatal Exception: java.lang.IllegalArgumentException: Cannot create PhoneAuthCredential without either verificationProof, sessionInfo, ortemprary proof.
       at com.google.android.gms.common.internal.Preconditions.checkArgument(Unknown Source:35)
       at com.google.firebase.auth.PhoneAuthCredential.(Unknown Source:6)
       at com.google.firebase.auth.PhoneAuthProvider.getCredential(Unknown Source:33)
       at com.firebase.ui.auth.ui.phone.PhoneNumberVerificationHandler.submitVerificationCode(PhoneNumberVerificationHandler.java:63)
       at com.firebase.ui.auth.ui.phone.SubmitConfirmationCodeFragment.submitCode(SubmitConfirmationCodeFragment.java:219)
       at com.firebase.ui.auth.ui.phone.SubmitConfirmationCodeFragment.access$100(SubmitConfirmationCodeFragment.java:45)
       at com.firebase.ui.auth.ui.phone.SubmitConfirmationCodeFragment$2.onClick(SubmitConfirmationCodeFragment.java:147)
       at android.view.View.performClick(View.java:6877)
       at android.widget.TextView.performClick(TextView.java:12651)
       at android.view.View$PerformClick.run(View.java:26069)
       at android.os.Handler.handleCallback(Handler.java:789)
       at android.os.Handler.dispatchMessage(Handler.java:98)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6938)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
FinalizerDaemon
   ...
OkHttp ConnectionPool
   ...
queued-work-looper
   ...
Queue
   ...
androidmapsapi-appenvironment-1
   ...

Device
Brand: samsung
Model: SM-G960F
Orientation: Portrait
RAM free: 1.09 GB
Disk free: 47.85 GB

Operating System
Version: 8.0.0
Orientation: Portrait
Rooted: No

Crash
Date: Jan 29, 2019, 3:56:00 PM

@samtstern or is it better to reopen a new issue about this?
let me know when more data is appreciated

Thanks @woutervegter for the info! Re-opened.

@samtstern same issue

Fatal Exception: java.lang.IllegalArgumentException: Cannot create PhoneAuthCredential without either verificationProof, sessionInfo, ortemprary proof.
       at com.google.android.gms.common.internal.Preconditions.checkArgument(Unknown Source:35)
       at com.google.firebase.auth.PhoneAuthCredential.(Unknown Source:6)
       at com.google.firebase.auth.PhoneAuthProvider.getCredential(Unknown Source:33)
       at com.myapp.activities.register.CodeVerificationActivity$1.onClick(SourceFile:79)
       at android.view.View.performClick(View.java:4780)
       at android.view.ViewDebug$3.run(ViewDebug.java:826)
       at android.os.Handler.handleCallback(Handler.java:756)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5278)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Device
Brand: TrendMicro
Model: GI-I9500_TMMARS
Orientation: Portrait
RAM free: 22.97 GB
Disk free: 41.19 GB

Operating System
Version: 5.1
Orientation: Portrait
Rooted: Yes

Moving this to the backlog milestone since I want to solve it but can't actually figure out why it's still occurring.

Note to sef: In the long term things like this would be better served by the new SavedState thing:
https://proandroiddev.com/saving-ui-state-with-viewmodel-savedstate-and-dagger-f77bcaeb8b08

Did you find any solution? I had the same problem too!

how to user insert data in one time if alleready submitted our details???

facing the same issue :

Fatal Exception: java.lang.IllegalArgumentException: Cannot create PhoneAuthCredential without either verificationProof, sessionInfo, ortemprary proof. at com.google.android.gms.common.internal.Preconditions.checkArgument(Preconditions.java:35) at com.google.firebase.auth.PhoneAuthCredential.(SourceFile:5) at com.google.firebase.auth.PhoneAuthProvider.getCredential(PhoneAuthProvider.java:33) at com.retranzinfolabs.superzopordering.activities.LoginActivity.showOtpDialog(LoginActivity.java:497) at com.retranzinfolabs.superzopordering.activities.LoginActivity.onClick(LoginActivity.java:356) at android.view.View.performClick(View.java:5293) at android.view.View$PerformClick.run(View.java:21653) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:227) at android.app.ActivityThread.main(ActivityThread.java:6102) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:961) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:822)


Devices
HTC Desire 10 pro
Redmi Note 5A
Galaxy A4
Galaxy J5(2016)
Galaxy J2
Galaxy J6
Galaxy J7
vivo
oppo A33f

Huawei Glory 9

Operating Systems
5.1.1
6.0
6.0.1
7.0
7.1.1
7.1.2
8.0.0

Same Problem: Both on Emulator & while USB Debugging on Andoroid Phone

/flutter (32276): PlatformException(error, Cannot create PhoneAuthCredential without either verificationProof, sessionInfo, ortemprary proof., null)

Same Problem: Both on Emulator & while USB Debugging on Andoroid Phone

/flutter (32276): PlatformException(error, Cannot create PhoneAuthCredential without either verificationProof, sessionInfo, ortemprary proof., null)

Here's the Code Snippet:

`Future verifyPhone() async {
final PhoneCodeAutoRetrievalTimeout autoRetrieve = (String verId) {
this.verificationId = verId;
};

final PhoneCodeSent smsCodeSent = (String verId, [int forceCodeResend]) {
  this.verificationId = verId;
  smsCodeDialog(context).then((value) {
    print("Signed In");
  });
};

final PhoneVerificationCompleted verifiedSuccess = (FirebaseUser) {
  print("verified");
};

final PhoneVerificationFailed veriFailed = (AuthException exception) {
  print("${exception.message}");
};

await FirebaseAuth.instance.verifyPhoneNumber(
    phoneNumber: this.phoneNo,
    codeAutoRetrievalTimeout: autoRetrieve,
    codeSent: smsCodeSent,
    timeout: const Duration(seconds: 5),
    verificationCompleted: verifiedSuccess,
    verificationFailed: veriFailed);

}

Future smsCodeDialog(BuildContext context) {
return showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return AlertDialog(
title: Text("Enter Sms Code"),
content: TextField(
onChanged: (value) {
this.smsCode = value;
},
),
contentPadding: EdgeInsets.all(10.0),
actions: [
FlatButton(
child: Text("Done"),
onPressed: () {
FirebaseAuth.instance.currentUser().then((user) {
if (user != null) {
Navigator.of(context).pop();
Navigator.of(context).pushReplacementNamed("/homepage");
} else {
Navigator.of(context).pop();

                  FirebaseAuth.instance
                      .signInWithCredential(PhoneAuthProvider.getCredential(
                          verificationId:
                              _PhoneNumberLoginState().verificationId,
                          smsCode: smsCode,
                          ))
                      .then((user) {
                        print(user.uid);
                        print(user.phoneNumber);
                    Navigator.of(context).pushReplacementNamed("/homepage");
                  }).catchError((e) {
                    print(e);
                  });
                }
              });
            },
          )
        ],
      );
    });

}`

still no solution in the thread closed without solution #1648 is also closed as duplicate of this . what are you doing @chitra-bahadur

I believe this error is thrown when an empty code is submitted to verifyPhoneNumber. I am using react-native-firebase and I fixed this by not submitting the code to Firebase if the code is not 6 digits long.

I too facing this issue in IONIC4. Is anyone found solution? please help I have already wasted 3days

For us this turned out to be related to the number we were using having been a real number but one that was whitelisted on the firebase console after it had been verified via SMS. See entry on fictional requirement for testing numbers (we were using a real number by mistake) -https://firebase.google.com/docs/auth/ios/phone-auth#test-with-whitelisted-phone-numbers

Check that your verification code isn't null:
for example assume that confirmResult :
const confirmResult = await auth().signInWithPhoneNumber(phonenumber)

const verifconde = this.state.verifcode.toString()
if(verifconde.length!=0){
confirmResult.confirm(verifconde)
.then(user => {
this.setState({ errMessag: "" })
this.register()
})
.catch(err => {
console.log("3ERRCONFI3", err)
this.setState({ errMessag: "Code invalide" })
this.changeLoading()
})
}else this.setState({ errMessag: "Invalide code" })

I tried to print the smsCode and VerificationID on every callback function fall under verifyPhoneNumber Method. The OTP is sent successfully, the problem arises when PhoneCodeAutoRetrievalTimeout function is called, at the point, I should be displaying a dialog for entering the received OTP. Somehow I managed to display the dialog but when the OTP is entered, the verification is turning into null.

I am trying to achieve Phone Authentication using BLoC Pattern (flutter_bloc package).

Everything is working fine when no proper architecture is followed.

I am kinda stuck with the BLoC pattern.

Restarted application in 1,769ms.
I/flutter ( 5462): sms : null
I/flutter ( 5462): verificationId : AM5PThBtoiJi-vTvibQfa3UkpdCKcEWaCn4k7vAtL4ugkbqOBPT4JmO5rinQYtxCIhqZ3rwwAaUp4wPHNtsQS1OOcL33LIHNhiAksSMngJuYluyXS0NoLwXozMl38Gbbik1cEmE2rRjXCUaXo3kcQ3twCkw9x4oPcQ
I/flutter ( 5462): codeAutoRetrieval
I/flutter ( 5462): sms : null
I/flutter ( 5462): verificationId : AM5PThBtoiJi-vTvibQfa3UkpdCKcEWaCn4k7vAtL4ugkbqOBPT4JmO5rinQYtxCIhqZ3rwwAaUp4wPHNtsQS1OOcL33LIHNhiAksSMngJuYluyXS0NoLwXozMl38Gbbik1cEmE2rRjXCUaXo3kcQ3twCkw9x4oPcQ
I/flutter ( 5462): sms : 123456
I/flutter ( 5462): verificationId : null
E/flutter ( 5462): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(error, Cannot create PhoneAuthCredential without either verificationProof, sessionInfo, temporary proof, or enrollment ID., null)

I faced this same issue. Found that this was happening when my UI was unable to update the smsCode: parameter to the value typed into the field. Checked my TextEditingControllerand found that I wasn't implementing this. Fixed it to update when the code is 6 digits long and it happened smoothly from there.

Add your apple secret key in your console firebase

Got this error when I send back empty string otp code to firebase. As long as the length of otp code is greater than 0, it won't crash and will return a proper error if the otp is invalid. In my case, I just disabled the submit button if the string length == 0 for a quick workaround

This also happens in a case where user tries to enter OTP before PhoneAuthProvider.OnVerificationStateChangedCallbacks -> onCodeSent method gets called. As we get String verificationId when onCodeSent is called we have to wait until that. Showing a loader or disabling verify OTP button until we receive the verificationId can do the trick here.

We've recently made a huge update to the Android SDK and please try with the latest SDK to see if the issue still persists. If so, please kindly open a new bug with the details and the version number you're using. Thanks!

I have faced this problem before, I was passing null value as SMS code, I made sure that I pass the real value and it worked.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

theHilikus picture theHilikus  ยท  3Comments

Nebneb picture Nebneb  ยท  3Comments

imax531 picture imax531  ยท  3Comments

RedCider picture RedCider  ยท  5Comments

ghost picture ghost  ยท  5Comments