Skip to content

Instantly share code, notes, and snippets.

@cablehead
Created March 12, 2015 06:10
Show Gist options
  • Save cablehead/668a410b464642c81870 to your computer and use it in GitHub Desktop.
Save cablehead/668a410b464642c81870 to your computer and use it in GitHub Desktop.
Google API OAuth from Command Line
import argparse
from oauth2client.client import flow_from_clientsecrets
from oauth2client.file import Storage
from oauth2client import tools
def main():
storage = Storage('a_credentials_file')
creds = storage.get()
print dir(creds)
return
flow = flow_from_clientsecrets(
'client_secrets.json',
scope='https://spreadsheets.google.com/feeds')
parser = argparse.ArgumentParser(parents=[tools.argparser])
flags = parser.parse_args()
credentials = tools.run_flow(flow, storage, flags)
print credentials
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment