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.
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.
let credentialURL = ...
let store = CredentialStore.default
if let token = try store.token(credentialURL) {
...
}let credentialURL = ...
let store = CredentialStore.default
try store.removeToken(credentialURL)