SwiftKeychainWrapper icon indicating copy to clipboard operation
SwiftKeychainWrapper copied to clipboard

Updating item only works on App restart

Open vivektakrani opened this issue 6 years ago • 0 comments

Hello, Thank you so much for such a wonderful wrapper. It was really easy to implement.

Issue : I am storing a token in the keychain on Login. Post login, I redirect the user to the dashboard screen where the token is passed in an API call. Ex : Keychain: token = "XYZ"

If the token is revoked due to log in on another device, the user gets an error of authentication, here I am removing the token and redirecting user back to login. Keychain: no token item or I can set it to empty string instead of removing.

Now, if I log in again, a new token is generated and saved in the keychain. Keychain: token = "ABC"

Post this, when dashboard API is called, token "XYZ" is passed instead of "ABC"

This happens only in the single lifecycle of the app. If I terminate/exit the app and open again, the token passed in the API is "ABC".

How can I update the existing key in the single lifecycle of the app? Is this the usual behavior or am I missing anything?

vivektakrani avatar Sep 03 '19 13:09 vivektakrani