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


Python oauth1.SIGNATURE_PLAINTEXT属性代码示例

本文整理汇总了Python中oauthlib.oauth1.SIGNATURE_PLAINTEXT属性的典型用法代码示例。如果您正苦于以下问题:Python oauth1.SIGNATURE_PLAINTEXT属性的具体用法?Python oauth1.SIGNATURE_PLAINTEXT怎么用?Python oauth1.SIGNATURE_PLAINTEXT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在oauthlib.oauth1的用法示例。


在下文中一共展示了oauth1.SIGNATURE_PLAINTEXT属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sign_request

# 需要导入模块: from oauthlib import oauth1 [as 别名]
# 或者: from oauthlib.oauth1 import SIGNATURE_PLAINTEXT [as 别名]
def sign_request(self, url, method, body, headers):
        """Sign a request.

        :param url: The URL to which the request is to be sent.
        :param headers: The headers in the request. These will be updated with
            the signature.
        """
        # The use of PLAINTEXT here was copied from MAAS, but we should switch
        # to HMAC once it works server-side.
        client = oauth1.Client(
            self.consumer_key,
            self.consumer_secret,
            self.token_key,
            self.token_secret,
            signature_method=oauth1.SIGNATURE_PLAINTEXT,
            realm=self.realm,
        )
        # To preserve API backward compatibility convert an empty string body
        # to `None`. The old "oauth" library would treat the empty string as
        # "no body", but "oauthlib" requires `None`.
        body = None if body is None or len(body) == 0 else body
        uri, signed_headers, body = client.sign(url, method, body, headers)
        headers.update(signed_headers) 
开发者ID:maas,项目名称:python-libmaas,代码行数:25,代码来源:__init__.py

示例2: __init__

# 需要导入模块: from oauthlib import oauth1 [as 别名]
# 或者: from oauthlib.oauth1 import SIGNATURE_PLAINTEXT [as 别名]
def __init__(self, apikey):
        self.consumer_key, self.token_key, self.token_secret = apikey.split(
            ':')
        self.consumer_secret = ""
        self.realm = "OAuth"

        self.oauth_client = oauth1.Client(
            self.consumer_key,
            self.consumer_secret,
            self.token_key,
            self.token_secret,
            signature_method=oauth1.SIGNATURE_PLAINTEXT,
            realm=self.realm) 
开发者ID:airshipit,项目名称:drydock,代码行数:15,代码来源:api_client.py

示例3: _get_oauth_headers

# 需要导入模块: from oauthlib import oauth1 [as 别名]
# 或者: from oauthlib.oauth1 import SIGNATURE_PLAINTEXT [as 别名]
def _get_oauth_headers(self, url):
        LOG.debug("Getting authorization headers for %s.", url)
        client = oauth1.Client(
            CONF.maas.oauth_consumer_key,
            client_secret=CONF.maas.oauth_consumer_secret,
            resource_owner_key=CONF.maas.oauth_token_key,
            resource_owner_secret=CONF.maas.oauth_token_secret,
            signature_method=oauth1.SIGNATURE_PLAINTEXT)
        realm = _Realm("")
        headers = client.sign(url, realm=realm)[1]
        return headers 
开发者ID:cloudbase,项目名称:cloudbase-init,代码行数:13,代码来源:maasservice.py

示例4: oauth_headers

# 需要导入模块: from oauthlib import oauth1 [as 别名]
# 或者: from oauthlib.oauth1 import SIGNATURE_PLAINTEXT [as 别名]
def oauth_headers(
    url, consumer_key, token_key, token_secret, consumer_secret, clockskew=0
):
    """Build OAuth headers using given credentials."""
    timestamp = int(time.time()) + clockskew
    client = oauth.Client(
        consumer_key,
        client_secret=consumer_secret,
        resource_owner_key=token_key,
        resource_owner_secret=token_secret,
        signature_method=oauth.SIGNATURE_PLAINTEXT,
        timestamp=str(timestamp),
    )
    uri, signed_headers, body = client.sign(url)
    return signed_headers 
开发者ID:maas,项目名称:maas,代码行数:17,代码来源:maas_api_helper.py

示例5: sign_request

# 需要导入模块: from oauthlib import oauth1 [as 别名]
# 或者: from oauthlib.oauth1 import SIGNATURE_PLAINTEXT [as 别名]
def sign_request(self, url, headers):
        """Sign a request.

        @param url: The URL to which the request is to be sent.
        @param headers: The headers in the request.  These will be updated
            with the signature.
        """
        client = oauth1.Client(
            self._consumer_key,
            resource_owner_key=self._resource_token,
            resource_owner_secret=self._resource_secret,
            signature_method=oauth1.SIGNATURE_PLAINTEXT,
        )
        _, signed_headers, _ = client.sign(url)
        headers.update(signed_headers) 
开发者ID:maas,项目名称:maas,代码行数:17,代码来源:maas_client.py


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