當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。