GTMAppAuth icon indicating copy to clipboard operation
GTMAppAuth copied to clipboard

Keychain sharing not working with app extension

Open phil1995 opened this issue 5 years ago • 2 comments

I am currently trying to access the last logged in user of the main app in an app extension. It seems that although keychain sharing is enabled in both and the main app and extension are in the same app group, the extension does not access the same keychain to restore the session. I first found this out when I implemented the login via GoogleSignIn. The function restorePrevoiusSignIn() works in the Main App as expected but not in the App Extension. Now that I have checked the source code of GTMAppAuth, it seems that the AccessGroup is not defined anywhere (and if so, where can it be defined)?

phil1995 avatar Feb 08 '20 15:02 phil1995

@phil1995 Have you found any solution to the issue? I'm trying to access the authorisation from the Widget Extension as well and it always returns false.

infinitetrooper avatar Jan 30 '21 16:01 infinitetrooper

GTMAppAuth stores auth state in the default keychain group. If you have the Keychain Sharing capability enabled and one or more keychain access groups defined, the default keychain group will be the first item in this list of keychain access groups. If your host app and app extension targets are both configured in this way, they should be able to share auth state.

https://developer.apple.com/documentation/security/keychain_services/keychain_items/sharing_access_to_keychain_items_among_a_collection_of_apps

petea avatar Dec 15 '21 21:12 petea