本文整理汇总了Python中oauth2client.client.AccessTokenCredentials方法的典型用法代码示例。如果您正苦于以下问题:Python client.AccessTokenCredentials方法的具体用法?Python client.AccessTokenCredentials怎么用?Python client.AccessTokenCredentials使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oauth2client.client
的用法示例。
在下文中一共展示了client.AccessTokenCredentials方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_service_object
# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import AccessTokenCredentials [as 别名]
def get_service_object(self, name):
service = GoogleAnalyticsHook._services[name]
if self.connection.password:
credentials = AccessTokenCredentials(self.connection.password,
'Airflow/1.0')
elif hasattr(self, 'client_secrets'):
credentials = ServiceAccountCredentials.from_json_keyfile_dict(self.client_secrets,
service.scopes)
elif hasattr(self, 'file_location'):
credentials = ServiceAccountCredentials.from_json_keyfile_name(self.file_location,
service.scopes)
else:
raise ValueError('No valid credentials could be found')
return build(service.name, service.version, credentials=credentials)
示例2: test_access_token_credentials
# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import AccessTokenCredentials [as 别名]
def test_access_token_credentials(self):
access_token = 'foo'
user_agent = 'refresh_checker/1.0'
credentials = client.AccessTokenCredentials(access_token, user_agent)
storage = file_module.Storage(FILENAME)
credentials = storage.put(credentials)
credentials = storage.get()
self.assertIsNotNone(credentials)
self.assertEquals('foo', credentials.access_token)
self.assertTrue(os.path.exists(FILENAME))
if os.name == 'posix': # pragma: NO COVER
mode = os.stat(FILENAME).st_mode
self.assertEquals('0o600', oct(stat.S_IMODE(mode)))
示例3: get_authenticated_service
# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import AccessTokenCredentials [as 别名]
def get_authenticated_service(self):
""" Create youtube oauth2 connection """
credentials = AccessTokenCredentials(
access_token=self.get_auth_code(),
user_agent='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'
)
return build(
'youtube', 'v3', http=credentials.authorize(httplib2.Http())
)
示例4: get_gdrive_credentials
# 需要导入模块: from oauth2client import client [as 别名]
# 或者: from oauth2client.client import AccessTokenCredentials [as 别名]
def get_gdrive_credentials(gms_ctx, app_id, app_sig):
gdrive_token = get_gdrive_access_token(gms_ctx, app_id, app_sig)
print(('GDrive token: %s' % gdrive_token))
if gdrive_token is None:
return None
cred = client.AccessTokenCredentials(gdrive_token, 'Mozilla/5.0 compatible')
cred.scopes.add(DRIVE_FILE)
cred.scopes.add(DRIVE_APPDATA)
return cred