Beispiel #1
0
parser = argparse.ArgumentParser(
    description=__doc__,
    formatter_class=argparse.RawDescriptionHelpFormatter,
    parents=[tools.argparser])


CLIENT_SECRETS = os.path.join(os.path.dirname(__file__),'client_secrets.json')

# Set up a Flow object to be used for authentication.
# Add one or more of the following scopes.
FLOW = client.flow_from_clientsecrets(CLIENT_SECRETS,
  scope=[
      'https://www.googleapis.com/auth/tasks',
      'https://www.googleapis.com/auth/tasks.readonly',
    ],
    message=tools.message_if_missing(CLIENT_SECRETS))


def connect(argv):
  # Parse the command-line flags.
  flags = parser.parse_args(argv[1:])

  # If the credentials don't exist or are invalid run through the native client
  # flow. The Storage object will ensure that if successful the good
  # credentials will get written back to the file.
  storage = file.Storage('credentials.dat')
  credentials = storage.get()
  if credentials is None or credentials.invalid:
    wx.MessageBox("Click OK to open webbrowser and authorize TaskCoach to access your Google Tasks",'Authorization',wx.OK|wx.ICON_INFORMATION)
    credentials = tools.run_flow(FLOW, storage, flags)
    if credentials is None: