本文整理匯總了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