ERROR_KEYCHAIN_ERROR SecItemAdd 100002
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
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
We keep hitting this. Restarting the app seems to fix it. Any suggestions about how to avoid restarting the app? Thank you!
Thanks for the report. This will be hard to debug without a reproducible example.