本文整理汇总了Python中oauthlib.common.Request.response_type方法的典型用法代码示例。如果您正苦于以下问题:Python Request.response_type方法的具体用法?Python Request.response_type怎么用?Python Request.response_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oauthlib.common.Request
的用法示例。
在下文中一共展示了Request.response_type方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_authorization_response
# 需要导入模块: from oauthlib.common import Request [as 别名]
# 或者: from oauthlib.common.Request import response_type [as 别名]
def create_authorization_response(self, uri, http_method='GET', body=None,
headers=None):
"""Extract response_type and route to the designated handler."""
request = Request(uri, http_method=http_method, body=body, headers=headers)
query_params = params_from_uri(request.uri)
body_params = request.decoded_body
# Prioritize response_type defined as query param over those in body.
# Chosen because the two core grant types utilizing the response type
# parameter both supply it in the uri. However it is not specified
# explicitely in RFC 6748.
if 'response_type' in query_params:
request.response_type = query_params.get('response_type')
elif 'response_type' in body_params:
request.response_type = body_params.get('response_type')
else:
raise errors.InvalidRequestError(
description='The response_type parameter is missing.')
if not request.response_type in self.response_types:
raise errors.UnsupportedResponseTypeError(
description='Invalid response type')
return self.response_types.get(
request.response_type).create_authorization_response(
request, self.default_token)
示例2: test_request_invalid_client_id
# 需要导入模块: from oauthlib.common import Request [as 别名]
# 或者: from oauthlib.common.Request import response_type [as 别名]
def test_request_invalid_client_id(self):
request = Request('https://a.b./path')
request.scope = 'openid profile'
request.response_type = 'code'
with pytest.raises(errors.MissingClientIdError):
self.auth.validate_authorization_request(request)
request.client_id = 'invalid_client'
self.validator.validate_client_id.return_value = False
with pytest.raises(errors.InvalidClientIdError):
self.auth.validate_authorization_request(request)
示例3: make_request
# 需要导入模块: from oauthlib.common import Request [as 别名]
# 或者: from oauthlib.common.Request import response_type [as 别名]
def make_request(self, response_type='code',
scope='openid profile email', **kwargs):
request = Request('https://a.b/path')
request.scope = scope
request.client = 'superman'
request.client_id = 'abcdef'
request.redirect_uri = 'https://a.b/'
request.response_type = response_type
for prop, val in kwargs.items():
setattr(request, prop, val)
return request