Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
baole opened this issue Jul 17, 2018 · 39 comments

Comments

@baole
Copy link

baole commented Jul 17, 2018

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

@samtstern
Copy link
Contributor

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

@SUPERCILEX
Copy link
Collaborator

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
Copy link
Author

baole commented Jul 18, 2018

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

@bulej93
Copy link

bulej93 commented Jul 18, 2018

am having this problem too

@samtstern
Copy link
Contributor

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

@SUPERCILEX
Copy link
Collaborator

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

🤣 So true

Anyway, submitted #1393

@baole
Copy link
Author

baole commented Jul 19, 2018

Great. Thanks @SUPERCILEX for the fix.

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

@samtstern
Copy link
Contributor

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

@samtstern
Copy link
Contributor

This was fixed and released in version 4.2.0

@KishanViramgama
Copy link

same problem

@wheelergames
Copy link

Me too

@NicWickman
Copy link

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

@samtstern
Copy link
Contributor

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

@woutervegter
Copy link

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 samtstern modified the milestones: 4.2.0, 4.3.2 Feb 4, 2019
@samtstern samtstern reopened this Feb 4, 2019
@samtstern
Copy link
Contributor

Thanks @woutervegter for the info! Re-opened.

@azaricstefan
Copy link

azaricstefan commented Feb 20, 2019

@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 samtstern removed this from the 4.3.2 milestone Mar 26, 2019
@samtstern samtstern added this to the backlog milestone Mar 26, 2019
@samtstern
Copy link
Contributor

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

@samtstern
Copy link
Contributor

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
Copy link

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

@hiten1comp
Copy link

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

@chitra-bahadur
Copy link

chitra-bahadur commented Jun 14, 2019

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
Copy link

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
Copy link

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
Copy link

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

@vpontis
Copy link

vpontis commented Nov 26, 2019

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
Copy link

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

@bars0um
Copy link

bars0um commented Dec 9, 2019

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
Copy link

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
Copy link

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
Copy link

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 TextEditingController and 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
Copy link

Add your apple secret key in your console firebase

@raibima
Copy link

raibima commented Jun 1, 2020

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
Copy link

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
Copy link
Member

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
Copy link

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
Copy link

@dombroks Thank you, you save my day

@AmaraRamzan
Copy link

@dombroks thanks, it works!

@AJVTdilsh
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests