I’m having trouble finding a particular keychain item with Xojo. I see the item in my Mac OS keychain item:
In Xojo the code looks like this:
Dim kc As KeyChain
Dim kci As KeyChainItem
for i as integer=0 to system.keychaincount
kc = New KeyChain(i)
If kc <> Nil Then
kci = New KeyChainItem
Try
kci.ServiceName = SearchField.Text
PasswordField.Text = kc.FindPassword(kci)//always get a Keychain exception here
ServiceNameField.Text = kci.ServiceName
AccountNameField.Text = kci.AccountName
CommentField.Text = kci.Comment
LabelField.Text = kci.Label
Catch e As KeyChainException
MsgBox("Keychain exception: " + e.Message)
End Try
End If
next
But no matter what I type into the SearchField, I can’t seem to find the item. The problem seems to be simply that I am not sure what the service name actually is (I’ve tried many…). Any pointers?
This is from the docs and use the Systems keychain
[code]
Dim ItemToFind as KeyChainItem
Dim password As String
ItemToFind = New KeyChainItem
'Indicate the name of the application whose keychain item you wish to find
ItemToFind.ServiceName = “MyApplication”
'get application’s password from the system keychain
password = System.KeyChain.FindPassword(ItemToFind)
MsgBox "The password for this item is: " + password
// query password
dim passwordData as MemoryBlock
if KeychainManagerMBS.GetPassword(query, passwordData) then
// and show it
dim password as string = DefineEncoding(passwordData, Encodings.utf8)
MsgBox "OK: "+password
else
MsgBox “Failed.”
end if
[/code]
is that enough?
Sorry, it doesn’t works with “Internetkennwort”.
I added a Xing account to the keychain as “Internetkennwort” but couldn’t access it. I tried different things and looked again into the docs. There I found the following info:
“KeyChain
Gives you access to the default Mac OS X Keychains for your applications. It is a Macintosh-only feature. The KeyChain class does not provide access to internet passwords.”
Ah, that makes sense. No, I didn’t get asked. But I was also wondering if an app should really be able access all internet passwords without user interaction (shudder…).
@Torsten Gaidies : Thanks for investigating. So the gist of it is: An App can access application keywords (as you did with Skype) but not internet keywords.
Here is my answer again, firstly my post was doubbled and as i deleted on of them, both seemed to be deleted after I logged out from the forum:
The Xojo framework doesn’t support access to internet keywords directly. With declares or the MBS plugin it should be possible (never tested it by myself).
at the top of my code makes no difference. I don’t get asked, and it just fails. Just tested it again on a different machine. BTW, I’m on Yosemite (10.10.1).