def get_credentials(): """ Read Authomatic credentials object from disk and refresh if necessary. """ file_path = os.path.expanduser(app_config.GOOGLE_OAUTH_CREDENTIALS_PATH) try: with open(file_path) as f: serialized_credentials = f.read() except IOError: return None credentials = authomatic.credentials(serialized_credentials) if not credentials.valid: credentials.refresh() save_credentials(credentials) return credentials
def get_credentials(): """ Read Authomatic credentials object from disk and refresh if necessary. """ file_path = os.path.expanduser(app_config.GOOGLE_OAUTH_CREDENTIALS_PATH) try: with open(file_path) as f: serialized_credentials = f.read() except IOError: return None credentials = authomatic.credentials(serialized_credentials) if not credentials.valid: credentials.refresh() save_credentials(credentials) return credentials