gthiruva Posted February 27, 2014 Share Posted February 27, 2014 Anyone know if Alfred has a way to search the Mac Keychain Access app? Or, is this something I can build with the workflow tool? Link to comment
jdfwarrior Posted February 28, 2014 Share Posted February 28, 2014 Anyone know if Alfred has a way to search the Mac Keychain Access app? Or, is this something I can build with the workflow tool? Alfred doesn't support that natively. It may be achievable with a workflow but I would be careful with this. Link to comment
rice.shawn Posted February 28, 2014 Share Posted February 28, 2014 The Alp library has some keychain integration, if I remember correctly. So if you're good with python, look into that one. Zach and gthiruva 2 Link to comment
gthiruva Posted March 13, 2014 Author Share Posted March 13, 2014 The Alp library has some keychain integration, if I remember correctly. So if you're good with python, look into that one. Slick! Thanks for the tip. gr8 1 Link to comment
gingerbeardman Posted October 4, 2018 Share Posted October 4, 2018 did you ever get anywhere with this? i am currently looking at doing something similar. https://ss64.com/osx/security.html security find-internet-password -a myaccount -s myservice -g ...but all i really need is a way to open keychain access with a predefined search term, however it does not have a URL Scheme of its own. Link to comment
deanishe Posted October 4, 2018 Share Posted October 4, 2018 URL schemes are poor man's automation used by iOS developers. AppleScript dictionaries is where it's at! Unfortunately, Keychain Access doesn't have one of those either Realistically, I think your best bet is "generic" AppleScript automation to simulate the input: tell application "Keychain Access" activate delay 0.5 -- wait for app to open/activate tell application "System Events" keystroke "f" using {command down, option down} -- ensure search bar is focussed keystroke "my search terms" -- enter search query end tell end tell luckman212 and gingerbeardman 2 Link to comment
CJK Posted October 6, 2018 Share Posted October 6, 2018 (edited) AppleScript's "KeyChain Access" is pretty terrible. However, the kind bloke(s) at Red-Sweater software (maker of FastScripts) have made a scripting addition aptly referred to as the Usable Keychain Scripting It allows you to search using whose filters as with other enumerated AppleScript collections, e.g. tell application "Usable Keychain Scripting" to tell ¬ the current keychain to get the ¬ password of every internet password ¬ whose name contains "google.com" Edited October 6, 2018 by CJK gingerbeardman and gr8 1 1 Link to comment
deanishe Posted October 6, 2018 Share Posted October 6, 2018 Are such additions also usable via JXA? It's a lot easier to generate Script Filter JSON from JS than from AppleScript, which is presumably what you'd want to do (i.e. show the results in Alfred). If you're messing about with passwords, this pasteboard script might be helpful. It marks the pasteboard data as "concealed", which Alfred's own Copy to Clipboard doesn't do. That's important to stop clipboard managers remembering the password. Link to comment
CJK Posted October 9, 2018 Share Posted October 9, 2018 On 10/6/2018 at 7:46 PM, deanishe said: Are such additions also usable via JXA? Yes, e.g.: var app = Application('Usable Keychain Scripting') app.currentKeychain.keychainItems.whose({name: {_contains: 'CK'} })() I don't have Mojave but I'm hearing lots and lots of reports that it's ballsed everything up for AppleScripters, particularly as it no longer permits the use of scripting additions (people wonder why I never use them, and this is why). However, as the Usable Keychain Scripting is an application, it can be scripted just like any other scriptable application that one downloads. deanishe 1 Link to comment
gingerbeardman Posted October 29, 2018 Share Posted October 29, 2018 On 10/6/2018 at 7:14 PM, CJK said: AppleScript's "KeyChain Access" is pretty terrible. However, the kind bloke(s) at Red-Sweater software (maker of FastScripts) have made a scripting addition aptly referred to as the Usable Keychain Scripting It allows you to search using whose filters as with other enumerated AppleScript collections, e.g. tell application "Usable Keychain Scripting" to tell ¬ the current keychain to get the ¬ password of every internet password ¬ whose name contains "google.com" This is very cool! I have been unable to figure out the scripting to access "Web form password" (Keychain parlance) which is what all the passwords I want to search are stored as. Basically, website passwords. Also, I recently discovered - likely somewhat belatedly - that I can copy the password of a keychain item by selecting its row and using the context menu. No need to open the item, unlock, select text, copy - which is what I have been doing for decades! Oops. Link to comment
CJK Posted October 31, 2018 Share Posted October 31, 2018 On 10/29/2018 at 12:10 PM, gingerbeardman said: I have been unable to figure out the scripting to access "Web form password" Web form passwords aren't part of the accessible keychain, either through Usable Keychain Scripting or regular Keychain Access apple scripting, or even through bash security program. I believe those are stored in the iCloud keychain, and not the login keychain. Such a pain, but possibly good from a security standpoint. Link to comment
gingerbeardman Posted November 11, 2018 Share Posted November 11, 2018 Ah, thanks for the info. Shame meanwhile I found this workflow: https://github.com/neilkimmett/keychain-workflow which wraps security find-internet-password -w -s {query} and may be useful to somebody reading this thread. Link to comment
gingerbeardman Posted January 21, 2019 Share Posted January 21, 2019 (edited) So I finally put together a workaround for this using UI scripting. https://www.gingerbeardman.com/alfred/Search Keychain.alfredworkflow Accept keyword and argument Launch Keychain Access via Alfred Workflow AppleScript focus search box, enter argument, copy password prompt, quit Keychain Access (user enter password and confirm) The core of it is the AppleScript: on alfred_script(q) activate application "Keychain Access" tell application "System Events" tell process "Keychain Access" set value of text field 1 of group 2 of toolbar 1 of window "Keychain Access" to q click button 1 of text field 1 of group 2 of toolbar 1 of window "Keychain Access" click menu item "Copy Password to Clipboard" of menu 1 of menu bar item "Edit" of menu bar 1 end tell end tell quit application "Keychain Access" end alfred_script Edited January 21, 2019 by gingerbeardman sin and gr8 1 1 Link to comment
rapatt Posted January 21, 2019 Share Posted January 21, 2019 Thanks gingerbeardman!! I was able to tweak yours just a bit to get it working with Mojave. Quick question. Do you know of a way to pass in an account with a service/platform to filter results? It tends to be sorted alphabetically if I just pass in "google.com" for example. Trying to filter out specific accounts. Link to comment
rogerz Posted February 8, 2019 Share Posted February 8, 2019 On 1/21/2019 at 7:41 PM, gingerbeardman said: So I finally put together a workaround for this using UI scripting. https://www.gingerbeardman.com/alfred/Search Keychain.alfredworkflow Accept keyword and argument Launch Keychain Access via Alfred Workflow AppleScript focus search box, enter argument, copy password prompt, quit Keychain Access (user enter password and confirm) The core of it is the AppleScript: on alfred_script(q) activate application "Keychain Access" tell application "System Events" tell process "Keychain Access" set value of text field 1 of group 2 of toolbar 1 of window "Keychain Access" to q click button 1 of text field 1 of group 2 of toolbar 1 of window "Keychain Access" click menu item "Copy Password to Clipboard" of menu 1 of menu bar item "Edit" of menu bar 1 end tell end tell quit application "Keychain Access" end alfred_script I have to modify "group 2" to "group 1" to make it work on Mojave gingerbeardman 1 Link to comment
gingerbeardman Posted February 26, 2019 Share Posted February 26, 2019 (edited) Sorry for the late response! Interesting the UI has changed in Mojave. A better way to do it in this instance, that will work in Mojave and earlier, is to say "last group" rather than "group X". I've changed the workflow to do this. Next, I have modified the workflow (same download) to have two keywords: pw = automatically copy first matching password (as it was before) kc = search and display all matches (I often use this) On 1/21/2019 at 6:38 PM, rapatt said: Thanks gingerbeardman!! I was able to tweak yours just a bit to get it working with Mojave. Quick question. Do you know of a way to pass in an account with a service/platform to filter results? It tends to be sorted alphabetically if I just pass in "google.com" for example. Trying to filter out specific accounts. I do not know how to filter search from the search field. One thing that helps is if you set your default column sorts in Keychain before you use this workflow. - click column header "Kind" (arrow points down = descending) this gives me a list with web form passwords at the top, a good match for use with "pw" keyword Another alternative is to create a new set of keychain entries for commonly searched for passwords with unique/shortcut names. Let me know how you get on! Edited February 26, 2019 by gingerbeardman Link to comment
thomasv Posted September 30, 2019 Share Posted September 30, 2019 @gingerbeardman Thanks for this great workflow, this is exactly what I needed! Are there any new developments since? I was looking at your script and have a suggestion which might be less prone to changes in the UI. You could replace the search/input part: set value of text field 1 of group 2 of toolbar 1 of window "Keychain Access" to q click button 1 of text field 1 of group 2 of toolbar 1 of window "Keychain Access" To something like this, using the menu bar instead: click menu item "Find" of first menu of menu bar item "Edit" of first menu bar keystroke q gr8 and gingerbeardman 1 1 Link to comment
gingerbeardman Posted November 11, 2019 Share Posted November 11, 2019 Thanks. I actually prefer to avoid clicking menu items but I'll compare performance and consider integrating your change that in future! Link to comment
gr8 Posted December 10, 2020 Share Posted December 10, 2020 Hi folks, I just tried this for the first time on Big Sur. The workflow for getting the first match works well, but the one for listing all matches doesn't. Did anyone get it to work? Thanks! Link to comment
gr8 Posted December 11, 2020 Share Posted December 11, 2020 Alright, I played with it and changes just minor things, and ended up with a version that works well for me. http://files.timbru.com/alfred/Search Keychain.alfredworkflow Some changes: Works on Big Sur Keyword ka without a parameter just launches Keychain Access Keyword ka with a parameter will launch Keychain Access and search for the keyword Using the Cmd+Shift modifier will copy the first search result, e.g. similar to the Keychain Access built-in behaviour Using the Cmd modifier will launch Keychain Access. Now that I type this, not sure if needed, I'll probably remove it. I hope it's useful to others. Have a nice day. cys and JJJJ 2 Link to comment
luckman212 Posted December 11, 2020 Share Posted December 11, 2020 @gr8 off topic but: what keystroke visualizer did you use for that screen recording? It doesn't look like any of the ones I know of: keycastr Mousepose Keystroke Pro Visualize Also slightly OT but, for quick retreival of encrypted secrets, I'm very happy with Bitwarden + blacs30/bitwarden-alfred-workflow. May be safer/faster than this scripting addition which seems to have been last updated in 2011. Link to comment
gr8 Posted January 18, 2021 Share Posted January 18, 2021 On 12/11/2020 at 5:09 PM, luckman212 said: @gr8 off topic but: what keystroke visualizer did you use for that screen recording? It was added with Camtasia, they have built in annotation feature. Link to comment
gingerbeardman Posted February 12, 2021 Share Posted February 12, 2021 (edited) On 12/11/2020 at 4:09 PM, luckman212 said: May be safer/faster than this scripting addition which seems to have been last updated in 2011. Seriously? I take offence at the viewpoint that if something hasn't been updated recently it must be bad/broken/untrustworthy. You may not be talking about my workflow, but: My workflow was created in 2019 It does not use a scripting addition It still works without issue (for me; I use it daily) and that's why it has not been updated It just automates user interactions, so there is no inherent unsafeness about it And it's very fast, not slow at all HTH Edited February 12, 2021 by gingerbeardman Link to comment
luckman212 Posted February 12, 2021 Share Posted February 12, 2021 (edited) @gingerbeardman Hey 👋 Happy Friday! I wasn't referring to your workflow actually. I was talking about Red Sweater's Usable Keychain Scripting (download). Edited February 12, 2021 by luckman212 gingerbeardman 1 Link to comment
gingerbeardman Posted February 12, 2021 Share Posted February 12, 2021 No worries. I don't use it in my workflow but that app still works just fine. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now