From Xojo Documentation


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.


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")
MessageBox("You don't have a key chain.")
End If

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