本文整理匯總了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)
示例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)
示例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
示例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
示例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)