Skip to content

Instantly share code, notes, and snippets.

@jkitching
Last active August 25, 2023 04:23
Show Gist options
  • Save jkitching/57baead775f6773848d2e334cc950999 to your computer and use it in GitHub Desktop.
Save jkitching/57baead775f6773848d2e334cc950999 to your computer and use it in GitHub Desktop.
import getpass
import json
import keyring
import subprocess
GOOGLE_ACCOUNT = 'your.email@gmail.com'
TOKEN_NAME = 'gpsoauth-token'
password = getpass.getpass('{} app password: '.format(GOOGLE_ACCOUNT))
input_string = '{}\n{}\n\n\n'.format(GOOGLE_ACCOUNT, password)
result = subprocess.run(
'docker run -i gpsoauth_login'.split(' '),
input=input_string.encode('utf-8'),
stdout=subprocess.PIPE
)
json_output = result.stdout.decode('utf-8')
master_token = json.loads(json_output)['Token']
keyring.set_password(TOKEN_NAME, GOOGLE_ACCOUNT, master_token)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment