简体   繁体   English

iOS中的OAuth令牌的钥匙串访问

[英]Keychain access in iOS for OAuth tokens

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. 我想使用适用于iOS的Keychain Services来存储OAuth访问令牌并刷新我的应用程序执行Web服务请求所需的令牌。 I've been reading the Keychain Services Programming Guide and I downloaded the GenericKeychain sample code, but I'm getting confused: 我一直在阅读《 钥匙串服务编程指南》,并下载了GenericKeychain示例代码,但我感到困惑:

  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. 我读到某个地方,您需要在会员中心中为应用程序ID及其关联的配置文件启用Data Protection 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? 但是,我没有阅读有关在Xcode中启用Data Protection以实现目标功能的任何信息,而且看来我仍然可以访问钥匙串……这很奇怪,但是我想我也应该在Xcode项目中启用Data Protection 。 , 对? Where is this Data Protection stuff described in Apple's docs? 苹果文档中描述的Data Protection内容在哪里? Is it somewhere said that I need to enable it for Keychain management? 是否有人说需要为Keychain管理启用它? I don't find it... 我没找到...
  3. Samples I found use the kSecClassGenericPassword class for the keychain items. 我发现的示例将kSecClassGenericPassword类用于钥匙串项目。 Since I want to manage OAuth related information, is there any better class I should use? 由于我要管理OAuth相关信息,因此我应该使用更好的类吗? Maybe kSecClassInternetPassword ? 也许kSecClassInternetPassword吗? What is the difference with kSecClassGenericPassword ? 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? 是否建议实例化一种KeychainWrapper类,还是最好将与钥匙串相关的方法作为类方法来访问?

Thanks in advance 提前致谢

Q3: According to Apple Q3:据苹果
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). 您使用Internet密码来通过Internet访问服务器和网站,并使用通用密码来访问任何其他受密码保护的服务(例如数据库或调度应用程序)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM