Skip to content

Chandlerdea/CredentialStorage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

A wrapper around URLCredentialStorage to store tokens and passwords in the keychain

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages