google / GoogleSignIn-iOS

Enables iOS and macOS apps to sign in with Google.
https://developers.google.com/identity/sign-in/ios
Apache License 2.0
472 stars 189 forks source link

iOS Widget - GIDSignIn Code=-4 (kGIDSignInErrorCodeHasNoAuthInKeychain) #363

Closed kevin-hv closed 7 months ago

kevin-hv commented 7 months ago

Description of the bug I have an application & a widget for iOS. I have a user logged in to my application via the GIDSIgnIn iOS SDK. When I try to use the GIDSignIn.sharedInstance.restorePreviousSignIn() function from my widget to restore the session in order to call the google APIs to fetch data which I need to update the Widget's UI, the function throws the GIDSignIn Code=-4 (kGIDSignInErrorCodeHasNoAuthInKeychain) error.

To Reproduce Steps to reproduce the behavior:

  1. Have an iOS app
  2. Have an iOS widget for the app
  3. Sign in in your iOS app with the GIDSignIn SDK
  4. Try to restore the sign in session in the iOS widget inside the AppIntentTimelineProvider's timeline(for configuration: ConfigurationAppIntent, in context: Context) async -> Timeline function

Expected behavior

Environment

kevin-hv commented 7 months ago

If anybody comes across this problem, I have seen that the keychain name GIDSignIn uses is auth, if you add this to keychain sharing on BOTH your app & your widget, it will work ^^.

Screenshot 2024-01-08 at 23 05 17