Python oauth2client.client 模块,AccessTokenCredentials() 实例源码

我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用oauth2client.client.AccessTokenCredentials()

项目:deb-python-oauth2client    作者:openstack    | 项目源码 | 文件源码
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)))
项目:REMAP    作者:REMAPApp    | 项目源码 | 文件源码
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)))
项目:Zoom2Youtube    作者:Welltory    | 项目源码 | 文件源码
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())
        )
项目:deb-python-oauth2client    作者:openstack    | 项目源码 | 文件源码
def setUp(self):
        access_token = 'foo'
        user_agent = 'refresh_checker/1.0'
        self.credentials = client.AccessTokenCredentials(
            access_token, user_agent,
            revoke_uri=oauth2client.GOOGLE_REVOKE_URI)
项目:REMAP    作者:REMAPApp    | 项目源码 | 文件源码
def setUp(self):
        access_token = 'foo'
        user_agent = 'refresh_checker/1.0'
        self.credentials = client.AccessTokenCredentials(
            access_token, user_agent,
            revoke_uri=oauth2client.GOOGLE_REVOKE_URI)
项目:oauth2l    作者:google    | 项目源码 | 文件源码
def _FetchCredentialWithSso(sso_cli, sso_email, scopes):
    """Fetch a credential with access_token fetched from the sso CLI."""
    commands = [sso_cli, sso_email] + scopes
    try:
        process = subprocess.Popen(
            commands, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        result, _ = process.communicate()
        if process.returncode != 0:
            raise Exception
    except:
        raise ValueError('Failed to fetch OAuth token by SSO.')

    return client.AccessTokenCredentials(
        result.strip(), _DEFAULT_USER_AGENT)
项目:hexopress    作者:joelewis    | 项目源码 | 文件源码
def get_credentials(googleuser):
    return client.AccessTokenCredentials(googleuser.access_token, 'web client')
项目:hexopress    作者:joelewis    | 项目源码 | 文件源码
def get_plus_service(googleuser):
    cred = client.AccessTokenCredentials(googleuser.access_token, 'web client')
    http_auth = cred.authorize(httplib2.Http())
    plus_service = discovery.build('plus', 'v1', http=http_auth)
    return plus_service
项目:hexopress    作者:joelewis    | 项目源码 | 文件源码
def get_credentials(googleuser):
    return client.AccessTokenCredentials(googleuser.access_token, 'web client')