Keychain.AddPassword

From Xojo Documentation

Method

Keychain.AddPassword(kci as KeychainItem, Password as String)

Supported for all project types and targets.

Adds the password to the Keychain and associates it with a KeychainItem. If it fails, it generates a KeychainException.

Example

The following example adds a KeychainItem for an application and assigns a password.

Var newItem As KeychainItem
If System.KeychainCount > 0 Then
newItem = New KeychainItem
// Indicate the name of the application
newItem.ServiceName = "MyApplication"

// Create a new keychain item for the application and assign the password
System.Keychain.AddPassword(newItem, "SecretPassword")
Else
Beep
MessageBox("You don't have a key chain.")
End If

Exception err As KeychainException
MessageBox("Can't add item: " + err.Message)