本文整理汇总了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)