Created
August 31, 2018 15:33
-
-
Save lukwam/e06a1f23d220f9321be266bca67a7674 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
def auth_stored_credentials(self, scopes=[]): | |
"""Authorize stored credentials.""" | |
# this has a dependence on oauth2client | |
if not scopes: | |
scopes = self.client_scopes | |
try: | |
parser = argparse.ArgumentParser(parents=[tools.argparser]) | |
parser.add_argument('args', nargs=argparse.REMAINDER) | |
flags = parser.parse_args() | |
flags.noauth_local_webserver = True | |
except ImportError: | |
flags = None | |
store = FileStorage(self.credentials_file) | |
credentials = store.get() | |
if not credentials or credentials.invalid: | |
flow = client.flow_from_clientsecrets( | |
self.client_secrets_file, | |
scopes, | |
) | |
flow.user_agent = self.app_name | |
if flags: | |
credentials = tools.run_flow(flow, store, flags) | |
# removed support for python 2.6 | |
# else: # Needed only for compatibility with Python 2.6 | |
# credentials = tools.run(flow, store) | |
print 'Saved credentials to ' + self.credentials_file | |
return credentials |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment