firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.47k stars 1.43k forks source link

ERROR_KEYCHAIN_ERROR SecItemAdd 100002 #12328

Open fbarbat opened 5 months ago

fbarbat commented 5 months ago

Description

Users sometimes hit keychain errors while logging in using Firebase Auth. We are using signInAsync(withCustomToken:) This is the specific error:

Error Domain=FIRAuthErrorDomain 
Code=17995 
"An error occurred when accessing the keychain. The NSLocalizedFailureReasonErrorKey field in the NSError.userInfo dictionary will contain more information about the error encountered" 
UserInfo={
FIRAuthErrorUserInfoNameKey=ERROR_KEYCHAIN_ERROR, 
NSLocalizedFailureReason=SecItemAdd (100002), 
NSLocalizedDescription=An error occurred when accessing the keychain. The NSLocalizedFailureReasonErrorKey field in the NSError.userInfo dictionary will contain more information about the error encountered
}

I used SecCopyErrorMessageString to understand what 100002 meant:

UNIX[No such file or directory]

But I don't have enough context to know how the Firebase SDK uses SecItemAdd and why it is getting that error.

The last time a user hit this, they hit it twice in a row. After restarting our app, it worked.

Reproducing the issue

Unfortunately, we don't have steps to reproduce the issue. But please let us know if you need us to add any logging or instrumentation into our app.

Firebase SDK Version

10.19.0

Xcode Version

15.0.1

Installation Method

Zip

Firebase Product(s)

Authentication

Targeted Platforms

macOS

Relevant Log Output

Unfortunately, as this is in prod, I don't have Firebase logs. These are part of our logs:

message
Error while logging in
Error
18:03:51

Error Domain=FIRAuthErrorDomain Code=17995 "An error occurred when accessing the keychain. The NSLocalizedFailureReasonErrorKey field in the NSError.userInfo dictionary will contain more information about the error encountered" UserInfo={FIRAuthErrorUserInfoNameKey=ERROR_KEYCHAIN_ERROR, NSLocalizedFailureReason=SecItemAdd (100002), NSLocalizedDescription=An error occurred when accessing the keychain. The NSLocalizedFailureReasonErrorKey field in the NSError.userInfo dictionary will contain more information about the error encountered}

http
POST https://www.googleapis.com/identitytoolkit/v3/relyingparty/getAccountInfo [200]
{
http.query: key=*, 
reason: no error, 
request_body_size: 1147, 
response_body_size: 0
}
Info
18:03:51

http
POST https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyCustomToken [200]
{
http.query: key=*, 
reason: no error, 
request_body_size: 772, 
response_body_size: 0
}

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

No response

If using CocoaPods, the project's Podfile.lock

No response

google-oss-bot commented 5 months ago

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

fbarbat commented 3 months ago

We keep hitting this. Restarting the app seems to fix it. Any suggestions about how to avoid restarting the app? Thank you!

paulb777 commented 2 months ago

Thanks for the report. This will be hard to debug without a reproducible example.