PasswordStore
Username/password credentials for servers, backed by the current platform's native password storage: Keystore-encrypted files on Android, internet-password items in the Apple Keychain and the macOS login keychain, Secret Service on Linux, or Credential Manager on Windows.
Like CredentialKeychain, operations are synchronous and may block or prompt the user, so call them from a worker thread. Nothing is ever persisted as plaintext; an unavailable or failing backend throws KeychainUnavailableException.
Entries are isolated by the store's service/account namespace and addressed by server and username. A PasswordStore and a CredentialKeychain created with the same names are independent: neither sees nor clears the other's entries.
Every platform accepts the same credentials. Servers and usernames must be nonblank and free of NUL, CR, and LF, and usernames are at most 512 characters. Passwords must be nonblank, free of NUL, CR, and LF, and at most 2,560 UTF-8 bytes.
val passwords = PasswordStore.forCurrentPlatform(serviceName = "my-app", accountName = "user-123")
passwords.save(PasswordCredential(server = "api.example.com", username = "alice", password = "s3cret"))
val alice: PasswordCredential? = passwords.find(server = "api.example.com", username = "alice")
val everyone: List<PasswordCredential> = passwords.findAll(server = "api.example.com")Types
Functions
Deletes every credential in this store's service/account namespace, for every server. Other namespaces and CredentialKeychain entries are untouched.
Saves credential, replacing any password already saved for its server and username.