Skip to content
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

Phone Auth not working above iOS 16 #13479

Closed
KunalxBhandari opened this issue Aug 12, 2024 · 10 comments · Fixed by #13539
Closed

Phone Auth not working above iOS 16 #13479

KunalxBhandari opened this issue Aug 12, 2024 · 10 comments · Fixed by #13539
Assignees
Milestone

Comments

@KunalxBhandari
Copy link

KunalxBhandari commented Aug 12, 2024

Description

I'm using the latest firebase version 11.0.0 and on iOS 16 and above, I'm unable to login using PhoneAuthProvider. I'm getting the below error message:

Error Domain=FIRAuthErrorDomain Code=17048 "Token mismatch" UserInfo={FIRAuthErrorUserInfoNameKey=INVALID_APP_CREDENTIAL, NSLocalizedDescription=Token mismatch}

Although it's working fine on 10.29.0 version.

Reproducing the issue

PhoneAuthProvider.provider().verifyPhoneNumber("+911234567899", uiDelegate: nil) { [weak self] (verificationID , error) in
if let error = error {
print(error)
let authErr = error as NSError
let alert = UIAlertController(title: "Something went wrong. Please try again later", message: nil, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "Ok", style: .default, handler: nil))
self?.present(alert, animated: true, completion: nil)
} else {
//Successful
}
}

Firebase SDK Version

11.0.0

Xcode Version

15.4

Installation Method

CocoaPods

Firebase Product(s)

Authentication

Targeted Platforms

iOS

Relevant Log Output

Error Domain=FIRAuthErrorDomain Code=17048 "Token mismatch" UserInfo={FIRAuthErrorUserInfoNameKey=INVALID_APP_CREDENTIAL, NSLocalizedDescription=Token mismatch}

If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet
Replace this line with the contents of your Package.resolved.

If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet
Replace this line with the contents of your Podfile.lock!
@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@ncooke3
Copy link
Member

ncooke3 commented Aug 12, 2024

Hi @KunalxBhandari, I wasn't able to reproduce this in v11. I tried Xcode 15 and Xcode 16 and used a device running iOS 17. When PhoneAuthProvider.provider().verifyPhoneNumber(...) is called, what behavior do you see? Does anything happen (e.g. recaptcha window appear, etc.) before the callback is called with the error?

cc: @jordanebelanger

@ncooke3
Copy link
Member

ncooke3 commented Aug 12, 2024

If the issue can be easily reproduced, it would be helpful to know where the error is being thrown as there are a few places within the phone provider logic where it could occur.

To debug, enable Swift error breakpoints, run the app, and perform the behavior that makes the error appear. Execution may pause on a few false positives, but what we are looking for are any breakpoints that pause execution in the PhoneAuthProvider.swift file.
Screenshot 2024-08-12 at 5 59 16 PM

Knowing where those pauses occur would help narrow things down.

@alexandersandberg
Copy link

alexandersandberg commented Aug 13, 2024

Possibly related:

Since Aug 8th, we've started seeing occasional INVALID_APP_CREDENTIAL errors for the google.cloud.identitytoolkit.v2.AuthenticationService.StartMfaSignIn method.

However, we're on Firebase iOS SDK version 10.24.0 since a while back. We have not made any recent changes on our side that could have caused this.

CleanShot 2024-08-13 at 14 15 54

@rizafran rizafran removed their assignment Aug 13, 2024
@deirinberg
Copy link

@ncooke3 we're having the same token mismatch as well. It's reproducible for us across multiple devices on 11.0. Everything was working great for us on 10.29 and earlier

I added a Swift Breakpoint Error and see that the verifyClient func in PhoneAuthProvider is failing. I get the following error message: Error Domain=FIRAuthErrorDomain Code=17048 "Token mismatch" UserInfo={NSLocalizedDescription=Token mismatch, FIRAuthErrorUserInfoNameKey=INVALID_APP_CREDENTIAL}

Not sure if this is relevant but the breakpoint was firing on the AuthBackendRPCImplementation callInternal func

@ncooke3
Copy link
Member

ncooke3 commented Aug 13, 2024

Thanks, @deirinberg. Question, does the Recaptcha UI flow get presented at all during the process?

@brett-a
Copy link

brett-a commented Aug 13, 2024

downgrading to 10.27 worked, thank you! not sure if 10.29 would work as well, I just chose 10.27.

otherwise, some relevant information:

I saw the recaptcha flow when I use the simulator, not when using the device.
not sure if this is helpful, I tried to add a breakpoint, but I don't really know how to interpret the output. Here's where it went however:

Screenshot 2024-08-13 at 6 41 28 PM

@deirinberg
Copy link

I don't see the recaptcha UI flow on device, haven't tested on simulator

@ncooke3
Copy link
Member

ncooke3 commented Aug 29, 2024

This has been fixed by #13539 and #13519. These fixes are staged to go out in the next Firebase release, 11.2.

@ncooke3 ncooke3 closed this as completed Aug 29, 2024
@ncooke3 ncooke3 added this to the 11.2.0 - M153 milestone Aug 29, 2024
@deirinberg
Copy link

thanks @ncooke3!

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