react-native-google-signin / google-signin

Google Sign-in for your React Native applications
https://react-native-google-signin.github.io/
MIT License
3.19k stars 878 forks source link

Keychain not persisting session after restarting app #1153

Closed rcidt closed 1 year ago

rcidt commented 1 year ago

Description

On iOS, I have the library working fine for the most part. But when I sign in, if I restart the app (kill and reopen), the signInSilently request fails with this error:

RNGoogleSignInError: The user has never signed in before with the given scopes, or they have since signed out., Error Domain=com.google.GIDSignIn Code=-4

The above does not happen if I reload the app via the developer menu (cmd+R).

In the Console app, I see the following logs after successfully calling signIn:

default 07:14:34.350965-0500    securityd   SecDbKeychainItemV7: serialized item exceeds reasonable size (6866 bytes)
default 07:14:34.352425-0500    myApp   keychain item data exceeds reasonable size (4899 bytes)
default 07:14:34.353126-0500    securityd   SecDbKeychainItemV7: item's secret data exceeds reasonable size (4972 bytes) (Q22QQV3L2L.com.google.GIDSignIn)

I am able to reproduce this issue in the simulator, real device, debug scheme, release scheme, etc. any configuration.

Code Sample

First I call configure

GoogleSignin.configure({
    scopes: ['https://www.googleapis.com/auth/calendar.events.readonly'],
    offlineAccess: false,
    iosClientId: MY_CLIENT_ID,
  })

Then I call signIn and get my tokens

await GoogleSignin.signIn()
const tokens = await GoogleSignin.getTokens()

Then on app restart, I call signInSilently

GoogleSignin.signInSilently()

Steps to Reproduce

Expected Behavior

signInSilently should return the user

Actual Behavior

signInSilently throws the aforementioned error

Environment

rcidt commented 1 year ago

Found the root cause. Seems like one of my dependencies (jitsi-meet) uses an older version of RNGoogleSignIn and there was produced a conflict.