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