1
votes

I'd like to use Keychain Services for iOS to store the OAuth access token and refresh token that my app need to perform Web services requests. I've been reading the Keychain Services Programming Guide and I downloaded the GenericKeychain sample code, but I'm getting confused:

  1. Code provided in document is different from the sample code... which approach should I follow?
  2. I read somewhere that you need to enable Data Protection in Member Center for the App ID and its associated provisioning profile. However, I didn't read anything about enabling Data Protection in Xcode for the target's capabilities, and it seems that I could access the keychain anyway... this is weird, but I guess I should enable Data Protection in the Xcode project as well, right? Where is this Data Protection stuff described in Apple's docs? Is it somewhere said that I need to enable it for Keychain management? I don't find it...
  3. Samples I found use the kSecClassGenericPassword class for the keychain items. Since I want to manage OAuth related information, is there any better class I should use? Maybe kSecClassInternetPassword? What is the difference with kSecClassGenericPassword?
  4. Is it recommended to instantiate a kind of KeychainWrapper class, or would it be better to access keychain related methods as class methods?

Thanks in advance

1
Theres a bunch of keychain wrappers out there you can make use of that will eliminate a lot of this complexity for you. Some of them as simple as using NSUserDefaults.Beau Nouvelle
@BeauYoung Thanks, I'm currently testing another one. But I still couldn't make clear about the questions 2 & 3...AppsDev

1 Answers

0
votes

Q3: According to Apple
documentation

You use Internet passwords for accessing servers and websites over the Internet, and generic passwords for any other password-protected service (such as a database or scheduling application).