KeychainWrap
A handy Keychain wrapper. It saves your OAuth2 tokens using WhenPasscodeSet ACL.
-
The service id. By default set to apple bundle id.
Declaration
Swift
public var serviceIdentifier: String -
The group id is Keychain access group which is used for sharing keychain content accross multiple apps issued from same developer. By default there is no access group.
Declaration
Swift
public var groupId: String? -
Initialize KeychainWrapper setting default values.
Declaration
Swift
public init(serviceId: String? = NSBundle.mainBundle().bundleIdentifier, groupId: String? = nil)Parameters
serviceIdunique service, defulated to bundleId
groupIdused for SSO between app issued from same developer certificate.
-
Save tokens information in Keychain.
Declaration
Swift
public func save(key: String, tokenType: TokenType, value: String) -> BoolParameters
keyusually use accountId for oauth2 module, any unique string.
tokenTypetype of token: access, refresh.
valuestring value of the token.
-
Read tokens information in Keychain. If the entry is not found return nil.
Declaration
Swift
public func read(userAccount: String, tokenType: TokenType) -> String?Parameters
userAccountkey of the keychain entry, usually accountId for oauth2 module.
tokenTypetype of token: access, refresh.
-
Clear all keychain entries. Note that Keychain can only be cleared progemmatically.
Declaration
Swift
public func resetKeychain() -> Bool
View on GitHub
KeychainWrap Class Reference