|
|
#1 |
|
All Star
Join Date: Sep 2006
Posts: 860
|
Getting password from keychain with applescript
I have been trying to get passwords from the keychain with apple script and have run into a few stumbling blocks, not really a surprise for me. This only has to do with simple Internet keychain items. Anyway, here is a list of problems. Any pointers are appreciated. Here is the script (code found here).
Code:
tell application "Keychain Scripting" launch tell current keychain tell (some Internet key whose name is "www.youtube.com"*) set myPW to password end tell end tell end tell return myPW Here is how I am searching for the items at the moment: tell (some Internet key whose name is "www.youtube.com") The problem I am running into here is that since July 09 or so Keychain has been adding the username of the account to the name. So for instance, the actual name in the keychain is "www.youtude.com (myloginname)". Question, how do I find the key without explicitly adding the (myloginname)? I want to be able to find this key by highlighting the web site name and evoking a service menu item. Problem 2 How can I eliminate the pop up dialogs that ask me if it is ok for the script to access my keychain? In my testing so far there are two times in which I have to choose OK in order to get one password. Also, are any of these goals made easier with the app Security? I have played with that and it is faster but will not just spit out the password, say to a file or clipboard. It seems to want to give all the info except the password to a pipe. Otherwise the password prints out fine on stout. Update: whoops. that is not the code. There is no * after "www.youtube.com"
__________________
Snow Leopard 10.6, MacBookPro1,1 Last edited by anika123; 01-11-2010 at 02:03 PM. |
|
|
|
|
|
#2 | |||||||||||||||||||
|
League Commissioner
Join Date: Mar 2003
Location: Kansas City
Posts: 11,347
|
You can try having a root level script run the security command to modify keychains. I have never had luck getting it to work and gave up on it.
__________________
sudo make me a sammich http://www.tlarkin.com "It just told me what I already knew, that I'm a great and amazing guy, didn't I tell you baby, I'm Zaphod Beeblebrox." |
|||||||||||||||||||
|
|
|
|
|
#3 | |||||||||||||||||||
|
All Star
Join Date: Sep 2006
Posts: 860
|
Turns out this part is pretty darn simple. Under keychain.app there are settings for each key that allow you to specify apps that are allowed to access a particular key. In this case adding "/System/Library/ScriptingAdditions/Keychain Scripting" to the allowed apps makes all the pop-ups go away and the script happily hands back my password.
__________________
Snow Leopard 10.6, MacBookPro1,1 |
|||||||||||||||||||
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|