Last active
August 25, 2023 04:23
-
-
Save jkitching/57baead775f6773848d2e334cc950999 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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