Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3773

Keychain.ServiceName wrong location

$
0
0

Hello guys.

Can someone test for me please if you get same result on tests before i submit a bug report.

So we have the sample code found in the official documentation

And it says the following

Sample code

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"

  Try
    ' Create a new keychain item for the application and assign the password
    System.Keychain.AddPassword(newItem, "SecretPassword")
  Catch error As KeychainException
    MessageBox("Can't add item: " + error.Message)
  End Try
Else
  System.Beep
  MessageBox("You don't have a key chain.")
End If

The following example retrieves the password and displays it in a message box.

Var itemToFind As KeychainItem
Var password As String

itemToFind = New KeychainItem
' Indicate the name of the application whose keychain item you wish to find
itemToFind.ServiceName = "MyApplication"

Try
  ' get application's password from the system keychain
  password = System.Keychain.FindPassword(itemToFind)
  MessageBox("The password for this item is: " + password)
Catch Exception error As KeychainException
  MessageBox("Can't find item: " + error.Message)
End Try

Now adding as well the code to remove the keychain item, supposedly .

Var itemToFind As KeychainItem

itemToFind = New KeychainItem
' Indicate the name of the application whose keychain item you wish to find
itemToFind.ServiceName = appName


If itemToFind <> Nil Then
  itemToFind.Remove
  
  MessageBox("Keychain Item Removed. ")
End If

Now, the first issue.

Screenshot 2024-03-10 at 18.56.09

AppNameTest in my case it should be under Name and not under Where.

Then it seems that the delete part does not do anything.

In my case tests were done on MacOS Ventura 13.6.5, M1 MacMini, And XOJO 2023R4

Thanks

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 3773

Trending Articles