Skip to content

Latest commit

 

History

History
35 lines (26 loc) · 928 Bytes

File metadata and controls

35 lines (26 loc) · 928 Bytes

CredentialStorage

CredentialStorage is a package that uses Apple's URLCredentialStorage APIs to store tokens and passwords in the user's keychain without the boilerplate associated with creating URLCredentials and URLProtectionSpaces.

As of now, the package only supports basic HTTP authentication with passwords.

How to use

Saving credentials

let loginURL = ...
let someToken...
let store = CredentialStore.default
try store.storeToken(someToken, userEmail, loginURL, nil)

Passing nil as the last parameter will use URLCredential.Persistence.permanent and store the token in the user's keychain.

Using credentials

let credentialURL = ...
let store = CredentialStore.default
if let token = try store.token(credentialURL) {
    ...
}

Removing credentials

let credentialURL = ...
let store = CredentialStore.default
try store.removeToken(credentialURL)