本文整理汇总了Python中oauthlib.oauth1.Client.disable_ssl_certificate_validation方法的典型用法代码示例。如果您正苦于以下问题:Python Client.disable_ssl_certificate_validation方法的具体用法?Python Client.disable_ssl_certificate_validation怎么用?Python Client.disable_ssl_certificate_validation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oauthlib.oauth1.Client
的用法示例。
在下文中一共展示了Client.disable_ssl_certificate_validation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_access_token
# 需要导入模块: from oauthlib.oauth1 import Client [as 别名]
# 或者: from oauthlib.oauth1.Client import disable_ssl_certificate_validation [as 别名]
def get_access_token(consumer_key,
consumer_secret,
req_token_key,
req_token_secret,
verifier,
access_token_url,
validate_certs=True):
method = 'GET'
params = {'format': 'json', 'oauth_callback': 'oob'}
# they're really serious about that oob
full_url = access_token_url + "&" + urllib.urlencode(params)
client = OAClient(consumer_key,
client_secret=consumer_secret,
resource_owner_key=req_token_key,
resource_owner_secret=req_token_secret,
verifier=verifier,
signature_type=SIGNATURE_TYPE_QUERY)
full_url, headers, body = client.sign(full_url, method)
client = httplib2.Http()
client.disable_ssl_certificate_validation = not validate_certs
resp, content = client.request(full_url, method=method)
try:
resp_dict = json.loads(content)
acc_token_key, acc_token_secret = resp_dict['key'], resp_dict['secret']
except:
raise ValueError('access token step failed: %s\n\nheaders, etc.: %s'
% (content, pformat(resp)))
return acc_token_key, acc_token_secret
示例2: make_api_call
# 需要导入模块: from oauthlib.oauth1 import Client [as 别名]
# 或者: from oauthlib.oauth1.Client import disable_ssl_certificate_validation [as 别名]
def make_api_call(consumer_key,
consumer_secret,
access_token_key,
access_token_secret,
method,
params,
api_url,
body=None,
headers=None):
headers = dict(headers or {})
method = method.upper()
params = dict(params, format='json')
if method == 'GET':
full_url = api_url + "?" + urllib.urlencode(params)
elif method == 'POST':
full_url = api_url
body = urllib.urlencode(params)
headers['Content-Type'] = 'application/x-www-form-urlencoded'
else:
raise ValueError('unsupported HTTP method %r' % method)
client = OAClient(consumer_key, client_secret=consumer_secret,
resource_owner_key=access_token_key,
resource_owner_secret=access_token_secret)
full_url, headers, body = client.sign(full_url, method, body, headers)
client = httplib2.Http()
client.disable_ssl_certificate_validation = True
resp, content = client.request(full_url,
method=method,
body=body,
headers=headers)
return content