firebase / FirebaseUI-Android

Optimized UI components for Firebase
https://firebaseopensource.com/projects/firebase/firebaseui-android/
Apache License 2.0
4.63k stars 1.84k forks source link

Cannot create PhoneAuthCredential without either verificationProof, sessionInfo, ortemprary proof. #1392

Closed baole closed 3 years ago

baole commented 6 years ago

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

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

samtstern commented 6 years ago

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

fabric
SUPERCILEX commented 6 years ago

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. 😊

baole commented 6 years ago

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

bulej93 commented 6 years ago

am having this problem too

samtstern commented 6 years ago

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

SUPERCILEX commented 6 years ago

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

🤣 So true

Anyway, submitted #1393

baole commented 6 years ago

Great. Thanks @SUPERCILEX for the fix.

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

samtstern commented 6 years ago

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

samtstern commented 6 years ago

This was fixed and released in version 4.2.0

KishanViramgama commented 5 years ago

same problem

wheelergames commented 5 years ago

Me too

NicWickman commented 5 years ago

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

samtstern commented 5 years ago

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

woutervegter commented 5 years ago

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

samtstern commented 5 years ago

Thanks @woutervegter for the info! Re-opened.

azaricstefan commented 5 years ago

@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

samtstern commented 5 years ago

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

samtstern commented 5 years ago

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

kostapostolakis commented 5 years ago

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

hiten1comp commented 5 years ago

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

chitra-bahadur commented 5 years ago

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

soberOOZ commented 5 years ago

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)

soberOOZ commented 5 years ago

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);
                  });
                }
              });
            },
          )
        ],
      );
    });

}`

zeeshan-mehdi commented 5 years ago

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

chitra-bahadur commented 5 years ago

@zeeshan-mehdi trying this solution https://github.com/firebase/FirebaseUI-Android/pull/1393/files/fcda2ec5b77b0f249a56a988a325551c16c98d29

vpontis commented 4 years ago

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.

lokichitti commented 4 years ago

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

bars0um commented 4 years ago

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

camarasidi12 commented 4 years ago

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" })

Alex-911 commented 4 years ago

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)

rahultumpala commented 4 years ago

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.

camarasidi12 commented 4 years ago

Add your apple secret key in your console firebase

raibima commented 4 years ago

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

rutvik106 commented 3 years ago

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.

yuchenshi commented 3 years ago

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!

dombroks commented 3 years ago

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.

muhamadrafipamungkas commented 3 years ago

@dombroks Thank you, you save my day

AmaraRamzan commented 1 year ago

@dombroks thanks, it works!

AJVTdilsh commented 1 year ago

i cannot fix this error can somebody help me

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.dilshanjagoda.dailychats, PID: 13358 java.lang.IllegalArgumentException: Cannot create PhoneAuthCredential without either sessionInfo + smsCode or temporary proof + phoneNumber. at com.google.android.gms.common.internal.Preconditions.checkArgument(com.google.android.gms:play-services-basement@@18.1.0:2) at com.google.firebase.auth.PhoneAuthCredential.(com.google.firebase:firebase-auth@@22.0.0:4) at com.google.firebase.auth.PhoneAuthCredential.zzc(com.google.firebase:firebase-auth@@22.0.0:1) at com.google.firebase.auth.PhoneAuthProvider.getCredential(com.google.firebase:firebase-auth@@22.0.0:1) at com.dilshanjagoda.dailychats.OTPActivity$2.onOtpCompleted(OTPActivity.java:77) at com.mukeshsolanki.OtpView.onTextChanged(OtpView.java:211) at android.widget.TextView.handleTextChanged(TextView.java:12019) at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:15206) at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:1278) at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:587) at androidx.emoji2.text.SpannableBuilder.replace(SpannableBuilder.java:315) at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:518) at androidx.emoji2.text.SpannableBuilder.replace(SpannableBuilder.java:305) at androidx.emoji2.text.SpannableBuilder.replace(SpannableBuilder.java:49) at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:945) at android.view.inputmethod.BaseInputConnection.setComposingText(BaseInputConnection.java:712) at android.view.inputmethod.InputConnectionWrapper.setComposingText(InputConnectionWrapper.java:165) at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:650) at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:118) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)