IOS Swift Where to store user Recorded data or OAuth token?

Everything is not so clear how it would be best to store the registered data on the users phone. Some people think that data like userID = 123 and loggedIn = true should be stored in NSUSerDefaults data. However, in my opinion, this data can be easily manipulated very little, according to this article, https://www.andyibanez.com/nsuserdefaults-not-for-sensitive-data/

So the question is: what is the best way to save data in the input, as the user navigates through different screens. The only data that needs to be saved is userID or OAuth Token , as well as several other user bits about the status of this user account. What is the safest way to store this data to make sure that someone cannot just fake another user when the data is retrieved from the server?

Regards, Michael

+5
source share
1 answer

NSUserDefaults API is a bad place to store the REST token and any sensitive data.
Since this is not a secure method, there is no encryption. In addition, it can be easily opened and read by reverse.

I suggest you store it in a keychain. The keychain is the best solution, as it is more secure and has encryption. See the IOS Keychain Services Help for more information on implementing keychain-enabled storage.

Also note that this is a rather time-consuming task, and you may be interested in 3-way libraries, key rings. I would recommend you the SSKeychain library or the GenericKeychain Apple sample project as a starting point.

+4
source

All Articles