Skip to content

GIDSignIn.signIn getting "keychain error" for some users #165

Closed

Description

@alperkayabasi

Hello,

We are using GoogleSignIn for a few years. Suddenly, some users start to get "com.google.GIDSignIn / error code: -2 / keychain error" and we can't sign them in to our application.

To fix this, I have to enable "keychain sharing access" in my project settings (we have never enabled this and it was working as expected for a long time) and add "com.google.GIDSignIn" as keychain group.
Here is the screenshot;
Screen Shot 2022-05-30 at 14 04 57
If I use my own bundle id here I still get the same error, I have to add com.google.GIDSignIn specifically.

This is not one of the steps to integrate the SDK and I don't know why it is neccessary to add "com.google.GIDSignIn" keychain sharing access in my project.

Can you help with the issue?
Thank you.

Activity

  1. petea commented on May 30, 2022

    @petea
    Contributor

    Can you tell me what version of Google Sign-In you're using when you see this behavior? The version of GTMAppAuth you're building with would also be relevant, as well as the version(s) of iOS you're seeing this on.

  2. tuando3i commented on May 31, 2022

    @tuando3i

    We are having the same problem here.

    • GMTAppAuth: 1.2.3
    • iOS version 15.5 (notice that it happens to some phones not happen with some other phones)
  3. AndyActionItem commented on May 31, 2022

    @AndyActionItem

    Also seeing this with iOS 15.5, but also iOS 14.7.1 . GTMAppAuth 1.2.3. It was reported today. Still looking to see if the version of iOS is a determining factor. This is an app that is in the store.
    Have now determined that updating to GTMAppAuth 1.3.0 solves the problem for our app at least.
    My Podfile has
    pod 'GoogleSignIn', '~> 5.0.1'
    and doing an pod update now gets me 1.3.0 instead of 1.2.3

  4. alperkayabasi commented on May 31, 2022

    @alperkayabasi
    Author
    • GoogleSignIn (6.1.0)
    • GTMAppAuth (1.2.2)

    The device I debugged was iOS 15.4.1 but there are many users who reported the issue, I don't know the OS versions of all.

  5. sopherwang commented on May 31, 2022

    @sopherwang

    I'm also having the same issue. Any suggestions would be great.

  6. longvudai commented on Jun 1, 2022

    @longvudai

    I'm also facing this issue today.

  7. petea commented on Jun 1, 2022

    @petea
    Contributor

    It sounds as though the Keychain is returning an error for some reason, causing GIDSignIn's -saveAuthState: to fail following a -signIn or -restorePreviousSignIn.

    Is anyone able to reliably reproduce this behavior in a debug build? If so, you could provide repro steps?

  8. alperkayabasi commented on Jun 2, 2022

    @alperkayabasi
    Author

    Yes I could debug it but there are no "steps" to reproduce the bug really, I just call GIDSignIn.sharedInstance.signIn method. It seems like device or user specific. You do same steps with two different devices, one logs in, one doesn't.

    All the users who had trouble logging in have an active Google session in Safari. Sadly, that's all I have.

  9. petea commented on Jun 2, 2022

    @petea
    Contributor

    If you can reproduce this in a debug build, try setting a breakpoint in GTMAppAuth's GTMKeychain implementation in the -setPasswordData:forService:accessibility:account:error: method and check the return value of the SecItemAdd call. A non-zero value of status could provide some insight into what type of a Keychain error we're dealing with.

  10. zaidhafeez commented on Jun 2, 2022

    @zaidhafeez

    The "keyChain Error" is not shown in an updated version of GTMAppAuth (1.3.0).
    Just updated to the newest version to resolve the error.

  11. zaidhafeez commented on Jun 2, 2022

    @zaidhafeez

    If you can reproduce this in a debug build, try setting a breakpoint in GTMAppAuth's GTMKeychain implementation in the -setPasswordData:forService:accessibility:account:error: method and check the return value of the SecItemAdd call. A non-zero value of status could provide some insight into what type of a Keychain error we're dealing with.

    The status returned in GTMAppAuth (1.2.2). is errSecDuplicateItem.

  12. petea commented on Jun 2, 2022

    @petea
    Contributor

    @zaidhafeez thanks for the feedback.

    For anyone who is (or was) experiencing this behavior, could you list all the third-party libraries you're using and how they're being built / linked (Swift Package Manager, CocoaPods, XCFrameworks, etc). I'm looking for a potential source of conflicting Keychain operations.

  13. iyouqiang commented on Jun 6, 2022

    @iyouqiang

    GoogleSignIn(5.0.2) iOS 14.6

  14. alperkayabasi commented on Jun 6, 2022

    @alperkayabasi
    Author

    I can verify that "keychain error" doesn't occur on GTMAppAuth version (1.3.0).
    It still persists on 1.2.2 though.

  15. petea commented on Jun 6, 2022

    @petea
    Contributor

    @alperkayabasi could you let me know which (if any) third-party libraries you're using in addition to Google Sign-In? Please see my previous comment.

  16. 29 remaining items

  17. hristoenev commented on Apr 26, 2024

    @hristoenev

    So the SDK created the auth record with missing entitlement and at some point in time it decided, that an entitlement is needed. That still does not explain why only switching back and forth between 7.0.0 and 7.1.0 without changing anything else in the project resulted in working with 7.0.0 and failing with 7.1.0

  18. apaolino commented on Jul 3, 2024

    @apaolino

    For anyone having the same issue on Flutter MacOS, I solved by using this dependency override:

    dependency_overrides:
      google_sign_in_ios: 5.7.5
    

    which uses GoogleSignIn 7.0.0. Which 7.1 I have the keychain error

  19. aryan1107 commented on Aug 29, 2024

    @aryan1107

    @apaolino Thanks so much I was stuck for few hours!

  20. vojtabohm commented on Oct 18, 2024

    @vojtabohm

    Why is this marked closed when the issue still persist in the latest version?

    GoogleSignin 7.1.0
    GTMAppAuth 4.1.1

    happens for some of our customers. Cannot reproduce on my own devices. They have macOS 15.0.1.

  21. krishsatya commented on Oct 21, 2024

    @krishsatya

    We're also seeing this error all of a sudden (not sure if it's specific to macOS 15 Sequoia). Ours is a macOS app using Firebase for auth. Unfortunately we're unable to reproduce this issue consistently. And there doesn't seem to be a workaround for users who do hit this issue.

    GoogleSignIn: 8.0.0
    GTMAppAuth: 4.1.1
    Firebase: 11.3.0
    GoogleAPIClientForREST: 4.0.0

  22. anishjain123 commented on Jan 14, 2025

    @anishjain123

    @krishsatya Were you able to solve this? been stuck on this for the last few hours

  23. jungti1234 commented on Jan 14, 2025

    @jungti1234

    @anishjain123 I'm still stuck too. I really have no idea what's causing that problem.

  24. longvudai commented on Feb 1, 2025

    @longvudai

    Downgrade to GoogleSignIn 7.0.0, then add keychain sharing to help me solve this problem.

  25. jungti1234 commented on Feb 3, 2025

    @jungti1234

    Downgrade to GoogleSignIn 7.0.0, then add keychain sharing to help me solve this problem.

    It works! You saved me.

    Then what's changed about it since 7.1.0?
    To be clear, I hadn't done anything other than update the version of GoogleSignIn to 7.1.0.

  26. paulotaylor commented on Feb 10, 2025

    @paulotaylor

    Just lost a few hours today with this issue. Downgrading GoogleSignIn to version 7 did the trick to me! Why isn't Google taking a deeper look at this more seriously?

  27. filipealva commented on May 15, 2025

    @filipealva

    Just lost a few hours today with this issue. Downgrading GoogleSignIn to version 7 did the trick to me! Why isn't Google taking a deeper look at this more seriously?

    same here

  28. drumkiller-peter commented on Jun 17, 2025

    @drumkiller-peter

    Still not workling for me

  29. allenlawson commented on Jul 1, 2025

    @allenlawson

    Also just lost a few hours today to this issue.

  30. brnnmrls commented on Jul 8, 2025

    @brnnmrls
    Member

    Hey everyone! I want to call out here that 9.0.0 is released and should fix the mac issue people have been posting about on this thread.

    We updated our README.md: https://github.com/google/GoogleSignIn-iOS?tab=readme-ov-file#google-sign-in-on-macos to reflect this change. You will need to add $(AppIdentifierPrefix)$(CFBundleIdentifier) to its keychain access group on mac in order to store credentials via the Keychain.

    Thanks to everyone for helping us move this forward!

  31. vojtabohm commented on Jul 9, 2025

    @vojtabohm

    Thank you for tackling this issue. While I cannot confirm it's fixed (I have few users), I am glad you're reading the threads and attending to them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions