OAuth2Securable

open class OAuth2Securable: OAuth2Requestable

Base class to add keychain storage functionality.

  • If set to true (the default) will use system keychain to store tokens. Use "keychain": bool in settings.

    Declaration

    Swift

    public var useKeychain = true
  • The keychain account to use to store tokens. Defaults to currentTokens.

    Declaration

    Swift

    open var keychainAccountForTokens = "currentTokens"
  • The keychain account name to use to store client credentials. Defaults to clientCredentials.

    Declaration

    Swift

    open var keychainAccountForClientCredentials = "clientCredentials"
  • Defaults to kSecAttrAccessibleWhenUnlocked. MUST be set via keychain_access_group init setting.

    Declaration

    Swift

    open internal(set) var keychainAccessMode = kSecAttrAccessibleWhenUnlocked
  • Keychain access group, none is set by default. MUST be set via keychain_access_group init setting.

    Declaration

    Swift

    open internal(set) var keychainAccessGroup: String?
  • Base initializer.

    Looks at the verbose, keychain, keychain_access_mode, keychain_access_group keychain_account_for_client_credentials and keychain_account_for_tokens. Everything else is handled by subclasses.

    Declaration

    Swift

    public init(settings: OAuth2JSON)
  • The service key under which to store keychain items. Returns http://localhost, subclasses override to return the authorize URL.

    Declaration

    Swift

    open func keychainServiceName() -> String
  • Items that should be stored when storing client credentials.

    Declaration

    Swift

    open func storableCredentialItems() -> [String: Any]?

    Return Value

    A dictionary with String keys and Any items

  • Stores our client credentials in the keychain.

    Declaration

    Swift

    open func storeClientToKeychain()
  • Items that should be stored when tokens are stored to the keychain.

    Declaration

    Swift

    open func storableTokenItems() -> [String: Any]?

    Return Value

    A dictionary with String keys and Any items

  • Stores our current token(s) in the keychain.

    Declaration

    Swift

    public func storeTokensToKeychain()
  • Unsets the client credentials and deletes them from the keychain.

    Declaration

    Swift

    open func forgetClient()
  • Unsets the tokens and deletes them from the keychain.

    Declaration

    Swift

    open func forgetTokens()