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
serviceId
unique service, defulated to bundleId
groupId
used 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) -> Bool
Parameters
key
usually use accountId for oauth2 module, any unique string.
tokenType
type of token: access, refresh.
value
string 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
userAccount
key of the keychain entry, usually accountId for oauth2 module.
tokenType
type of token: access, refresh.
-
Clear all keychain entries. Note that Keychain can only be cleared progemmatically.
Declaration
Swift
public func resetKeychain() -> Bool