当前位置: 首页>>代码示例>>Python>>正文


Python client.AccessTokenCredentials方法代码示例

本文整理汇总了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) 
开发者ID:airflow-plugins,项目名称:google_analytics_plugin,代码行数:19,代码来源:google_analytics_hook.py

示例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))) 
开发者ID:haynieresearch,项目名称:jarvis,代码行数:20,代码来源:test_file.py

示例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())
        ) 
开发者ID:Welltory,项目名称:Zoom2Youtube,代码行数:11,代码来源:youtube.py

示例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 
开发者ID:nelenkov,项目名称:gdrive-appdata,代码行数:13,代码来源:get-gdrive-appdata.py


注:本文中的oauth2client.client.AccessTokenCredentials方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。