ODClient.loadCurrentClient() can get to a state where it can never load the current client. #85
Comments
Hi @friedtofu, thanks for reporting this issue. I'm unable to reproduce the issue as described above - my steps were as follows:
Upon relaunching the app, it correctly loads the last session and is able to execute requests against the service.
I have a couple questions here - first, when you say 'account id' are you referring to the long (~32 character) hexadecimal string, or are you referring to the user's email address, or something else? I'm also not clear on which part of the code you are referring to. Are you referring to ODAccountStore.m where it performs the following: if (currentAccountId){
[self.logger logWithLevel:ODLogVerbose message:@"Loading %@ as current account", currentAccountId];
ODAccountSession *currentSession = self.accountSessions[currentAccountId]; Or are you referring to something inside keychainWrapper? Finally:
What is the behavior you observe when you try to call ODClient.loadCurrentClient once it enters this state? Thanks, |
Hi Kevin, There is a bug in ODAccountStore in especially this part:
the currentSession.accountId is lowercase due to the fact that the keychain saves it that way. The variable currentAccountId above will be caseSensitive (upper and lower case) If you do the steps I describe above, you should be able to hit this state. It will always hit this part of the conditional statement:
|
If it helps, look at the definition of this function in KeyChainWrapper In the ADALib , they lowercase the accountItem userId , where the ODAccountStore serialize/deserialize the session as-in with full-case characters. |
See the referenced PR. I still have not been able to reproduce the issue because the account ID's returned by the service seem to be lowercase for me already, but I believe this should resolve the issue you described. Just to be sure - are the account ID's that you see hexadecimal strings, but uppercase? Or are they some other format altogether? If they are some other format I may need to follow up with the MSA team to ensure we aren't breaking any semantics by normalizing like this. |
An example string of what the account ID is this : AAAAAAAAAAAAAAAAAAAAAGK3KXtotU-qFymJnsZ7FUI I ended up having to write my own custom AccountStore. |
Agreed, this is pretty serious - I'm surprised we haven't seen it before. I will do some digging on my end. |
Issue should be resolved with latest commit - if it recurs, please reopen this issue. Thanks! |
@friedtofu @kevklam I'm grabbing the latest branch through cocoapods but I'm still having the same issue with "OneDrive SDK ERROR : Failed to load AAAAAAAAAAAAAAAAAAAAAGj1ZW6pev9i2e1yo_9l0hY as current account" every time I call loadCurrentClient and loadClients remains empty, after successfully calling clientWithCompletion, and then inside setCurrentClient and storeCurrentAccount. What am I missing? |
I have the same issue |
Repro step:
Reason:
The OneDriveSDK upon sign in does this:
Sign in:
What happens when we kill and relaunch the app and attempt to access the current client?
Because both of the currentSession and accountId stored in the map are case-sensitive , the look up will succeed. We can find all of the account information associate with this session.
IF NOTHING triggers “storeAccounts”, then everything will work fine because nothing new gets saved.
However, since the OneDriveSDK supports automatic refreshing token, upon succeeding the refresh, it will call ‘storeAccounts’ , and rewrite the “currentSession” to a file in lowercase.
The next time the application loads, it will not be able to find a matching account information due to case-mismatch.
We can no longer call ODClient.loadCurrentClient()
The text was updated successfully, but these errors were encountered: