Jump to content
hoody

How to copy a password from 1password?

Recommended Posts

In 1Password, there is a type called "Passwords", which saves passwords only. 

 

It seems the Alfred 1Passwords integration only works with the "Logins" type password. But sometimes, I only need to get a password I saved before. I would like Alfred to copy the password to the clipboard. For example, I need to login MySQL database from terminal, but I don't remember the password. I would like to fire alfred to copy the password from 1Password.

 

Is there a way to do it?

 

Thanks.

Share this post


Link to post

In 1Password, there is a type called "Passwords", which saves passwords only. 

 

It seems the Alfred 1Passwords integration only works with the "Logins" type password. But sometimes, I only need to get a password I saved before. I would like Alfred to copy the password to the clipboard. For example, I need to login MySQL database from terminal, but I don't remember the password. I would like to fire alfred to copy the password from 1Password.

 

Is there a way to do it?

 

Thanks.

 

Umm the way how i do it is, opening 1password with a search term and then send keycodes to it via applescript.

 

Here is an example for a game called league of legends: https://www.dropbox.com/s/dus9sxywxv4dw9i/1password%20mini.alfredworkflow?dl=0

 

Keep in mind that 1password has to be unlocked before you start.

To change it to your use, just change this applescript part:

open location "x-onepassword-helper://search/league"
delay 1

Gotta have to check how your what your stuff is exactly name. Just replace "league" with your term.

Then you have to take a look at the next applescript that's called:

tell application "System Events" to tell process "1Password mini"
	set frontmost to true
	key code 124
	delay 1
	key code 36
end tell

For a normal login copy it does press "Right arrow" and then "Return" after a delay. For your case you gotta have to add "key code 126"

and then press "Return" i guess like this:

tell application "System Events" to tell process "1Password mini"
	set frontmost to true
	key code 124
	delay 1
        key code 126
        delay 1
	key code 36
end tell

 

Gotta have to play with the delay and see what's the best.

Here is a website for all the possible key codes.

Maybe someone else knows a better way, but that's how i do it atm ^^

 

Hope this helps :)

Edited by FroZen_X

Share this post


Link to post

The above method stopped working with 1Password 7 because 1Password mini no longer exists. Here's an updated AppleScript which should help others.

 

open location "onepassword://extension/search/{query}"

tell application "System Events" to tell process "1Password 7"
	set frontmost to true
	delay 0.7
	key code 48
	delay 0.2
	key code 124
	delay 0.2
	key code 125
	delay 0.2
	key code 36
end tell

Basically this opens the "mini" like app that actually runs as an extension in the main 1Password 7 process, inputs the query from the first object (or you can hard code it to search for a specific app), sends the tab key code to select the first search result, sends right arrow to select the username, sends down arrow to select password, and sends return key to copy it to the clipboard.

Share this post


Link to post

I made a version that's a bit faster and also restores focus to the frontmost app when called. You may need to add in some delays.

 

https://github.com/delikat/alfred-workflows/raw/master/1Password Copy.alfredworkflow

tell application "System Events"
	set frontmostApplicationName to name of 1st process whose frontmost is true
	open location "onepassword://extension/search/{query}"
	set frontmost of process "1Password 7" to true
	key code 48
	key code 124
	key code 125
	key code 36
	set frontmost of process frontmostApplicationName to true
end tell

 

Share this post


Link to post

This is great. Is there any way to pop-up a list of so I know when my search has reduced to a single item?

 

On 10/19/2019 at 8:08 PM, delikat said:

I made a version that's a bit faster and also restores focus to the frontmost app when called. You may need to add in some delays.

 

https://github.com/delikat/alfred-workflows/raw/master/1Password Copy.alfredworkflow


tell application "System Events"
	set frontmostApplicationName to name of 1st process whose frontmost is true
	open location "onepassword://extension/search/{query}"
	set frontmost of process "1Password 7" to true
	key code 48
	key code 124
	key code 125
	key code 36
	set frontmost of process frontmostApplicationName to true
end tell

 

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...