Fill the blank
The token is only used while the app is open and must not move to another device. Fill the blank.
let query: [String: Any] = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrService as String: "com.example.auth",
kSecAttrAccount as String: "accessToken",
kSecValueData as String: Data(token.utf8),
kSecAttrAccessible as String: ____
]
let status = SecItemAdd(query as CFDictionary, nil)Hint 1 of 1
Two requirements: when unlocked, and this device only.
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A kSecAttrAccessibleWhenUnlockedThisDeviceOnly
Correct. It's readable only while unlocked and never migrates.
Why not the others?
- B
kSecAttrAccessibleAfterFirstUnlock. It stays readable while locked and can move to a new device through a backup. - C
kSecAttrAccessibleAlways. It's deprecated and readable even when locked. - D
kSecClassInternetPassword. That is an item class, not an accessibility value.