Skip to content

Instantly share code, notes, and snippets.

@athrabeth
Created July 12, 2015 05:21
Show Gist options
  • Save athrabeth/1f44cce1bb615bcf3185 to your computer and use it in GitHub Desktop.
Save athrabeth/1f44cce1bb615bcf3185 to your computer and use it in GitHub Desktop.
Combining Passpie and Onetimepass
#!/usr/local/bin/python
import clipboard
import onetimepass as otp
import getpass
import subprocess
'''
1. if you already have a google authenticator added to your google account, remove it
2. add another one, and click the link under the barcode to get the key
3. remove the spaces and lower case the whole thing
4. add the key to passpie
'''
# prompt user for passpie password
passphrase = getpass.getpass("passphrase: ")
# get key from passpie
# <name@address> is assumed to be the entry from passpie
command = "passpie copy --passphrase '%s' --to stdout <name@address>" % passphrase
key = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE).stdout.read()
# the key comes back with a newline, so lets get rid of that
key = key.replace('\n','')
# generate token
# put token silently into clipboard
code = otp.get_totp(key)
clipboard.copy(str(code))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment