Skip to content

Instantly share code, notes, and snippets.

@felipeborges
Created June 15, 2017 14:22
Show Gist options
  • Save felipeborges/5a9812f06f2ee9b9b15fc4c9b8f198f8 to your computer and use it in GitHub Desktop.
Save felipeborges/5a9812f06f2ee9b9b15fc4c9b8f198f8 to your computer and use it in GitHub Desktop.
Get Google API credentials from GNOME Online Accounts
import gi
gi.require_version('Goa', '1.0')
from gi.repository import Goa
def main(args):
client = Goa.Client.new_sync (None)
accounts = client.get_accounts ()
for obj in accounts:
account = obj.get_account ()
if account.props.provider_name == "Google":
oauth2 = obj.get_oauth2_based ()
break
if oauth2 is None:
sys.exit ()
print (oauth2.props.client_id)
print (oauth2.props.client_secret)
print (oauth2.call_get_access_token_sync(None))
return 0
if __name__ == '__main__':
import sys
sys.exit(main(sys.argv))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment