firebase-ios-sdk icon indicating copy to clipboard operation
firebase-ios-sdk copied to clipboard

[11.3.0] Auth: macOS not working "required entitlement" error

Open Vincz opened this issue 1 year ago • 1 comments

Description

There is an issue with Firebase Auth with macOS.
By default, on a brand new project, running this code:

func signIn(email: String, password: String) {
        print("Signin \(email)")
        Auth.auth().signIn(withEmail: email, password: password) { result, error in
            print("Result signin \(result), error \(error?.localizedDescription ?? "")")
            if let error = error {
                print((error as NSError).userInfo)
        }
    }
}

Will result with the following error (if the credentials are correct) : Result signin nil, error An error occurred when accessing the keychain. The NSLocalizedFailureReasonErrorKey field in the NSError.userInfo dictionary will contain more information about the error encountered ["NSLocalizedDescription": "An error occurred when accessing the keychain. The NSLocalizedFailureReasonErrorKey field in the NSError.userInfo dictionary will contain more information about the error encountered", "FIRAuthErrorUserInfoNameKey": "ERROR_KEYCHAIN_ERROR", "NSLocalizedFailureReason": "SecItemAdd (-34018) A required entitlement isn\'t present."]

Adding the Keychain sharing capability with a group and running the code again, will result in the signIn completion handler never get called.

The same code is working as expected in IOS simulator.

Reproducing the issue

No response

Firebase SDK Version

11.3

Xcode Version

16.0

Installation Method

Swift Package Manager

Firebase Product(s)

Authentication

Targeted Platforms

iOS, macOS

Relevant Log Output

No response

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!

Vincz avatar Oct 19 '24 11:10 Vincz

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

google-oss-bot avatar Oct 19 '24 11:10 google-oss-bot

Yes! I had this issue too but adding Keychain Sharing Capability fixed it.

djryanash avatar Oct 21 '24 05:10 djryanash

Hi guys. Any update regarding these issue. Is there any way we can display more debug from Firebase to understand the issue?

Vincz avatar Nov 11 '24 09:11 Vincz

After more testing, it appears that adding the Keychain Sharing with the app itself fix the issue. Maybe it should be worth mentioning in the docs?

Vincz avatar Nov 11 '24 16:11 Vincz

Hi @Vincz, it is mentioned on the FAQ page: https://firebase.google.com/docs/ios/troubleshooting-faq#macos-keychain-sharing but I agree it could be more helpful to mention it elsewhere as well. Which docs were you looking at? Also, was this a new app or was the issue encountered when upgrading an existing app?

ncooke3 avatar Nov 11 '24 17:11 ncooke3

Hi @ncooke3! I was looking at these https://firebase.google.com/docs/auth/ios/start It was during the creation of a new app but I also realized that an old app that uses to work before wasn't working anymore (maybe since the migration to Sequoia, but I'm not sure). Anyway, it could be a good idea to add a mention about that in the Get started section, cause honestly, I never came across the page you mentioned while searching for my issue.

Vincz avatar Nov 11 '24 17:11 Vincz

I've since updated those docs to call this out:

Screenshot 2024-11-11 at 9 09 22 PM

I'm going to mark this issue as closed now. Don't hesitate to reach out if you run into any more issues. Thanks!

ncooke3 avatar Nov 12 '24 02:11 ncooke3