Open crspybits opened 3 years ago
It seems like what is called for here is to get rid of the periodic credentials refresh that I've been doing, and only if we get an unauthorized response from our server, to then do a credentials refresh. IIRC this is what I was doing on Neebla v1. This is not a particularly simple fix.
I'm going to keep the periodic refresh also, but change it to not do the refresh when the app launches. The new iOSBasics
credentials refresh in CredentialsRefresh
will take care of the initial refresh for credential when the app launches. The other, periodic, refreshes will deal with other network requests-- which are done using a background URLSession and not amenable to the strategy used by CredentialsRefresh
. I.e., we can't easily restart these requests on a failure due to stale credentials.
I've been getting reports of users being signed out when the app launches. This shouldn't happen.
From error logs and from code tracing, the sequence seems to be:
1) The app launches. 2) The
appLaunchSetup(userSignedIn
for the credentials (e.g.,iOSGoogle
) gets called. 3) That credentials method calls theGenericSignInDelegate
methodsignInCompleted
. 4) That call leads to a call toiOSBasics
internal methodcompleteSignInProcess
5) That method callsapi.checkCreds
If it has been a while since the app was last launched the sign in credentials may have expired. This leads to the
api.checkCreds
call to receive anunauthorized
response from the server, and the user is then signed out.While I do do a refresh credentials when the app starts, that's insufficient. At best there is a race condition between that credentials refresh and the above
api.checkCreds
.