本文整理汇总了Python中oic.oic.message.AccessTokenResponse.to_urlencoded方法的典型用法代码示例。如果您正苦于以下问题:Python AccessTokenResponse.to_urlencoded方法的具体用法?Python AccessTokenResponse.to_urlencoded怎么用?Python AccessTokenResponse.to_urlencoded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oic.oic.message.AccessTokenResponse
的用法示例。
在下文中一共展示了AccessTokenResponse.to_urlencoded方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parse_access_token_response
# 需要导入模块: from oic.oic.message import AccessTokenResponse [as 别名]
# 或者: from oic.oic.message.AccessTokenResponse import to_urlencoded [as 别名]
def test_parse_access_token_response():
client = Client()
at = AccessTokenResponse(access_token="SlAV32hkKG", token_type="Bearer",
refresh_token="8xLOxBtZp8", expires_in=3600)
atj = at.to_json()
ATR = AccessTokenResponse
atr = client.parse_response(ATR, info=atj)
assert _eq(atr.keys(), ['access_token', 'token_type', 'expires_in',
'refresh_token'])
uec = at.to_urlencoded()
raises(ValueError, 'client.parse_response(ATR, info=uec)')
uatr = client.parse_response(ATR, info=uec, sformat="urlencoded")
assert _eq(uatr.keys(), ['access_token', 'token_type', 'expires_in',
'refresh_token'])
huec = "%s?%s" % ("https://example.com/token", uec)
uatr = client.parse_response(ATR, info=huec, sformat="urlencoded")
assert _eq(uatr.keys(), ['access_token', 'token_type', 'expires_in',
'refresh_token'])
err = ErrorResponse(error="invalid_request",
error_description="Something was missing",
error_uri="http://example.com/error_message.html")
jerr = err.to_json()
uerr = err.to_urlencoded()
_ = client.parse_response(ATR, info=jerr)
_ = client.parse_response(ATR, info=uerr, sformat="urlencoded")
raises(Exception,
'client.parse_response(ATR, info=jerr, sformat="urlencoded")')
raises(Exception, "client.parse_response(ATR, info=uerr)")
raises(Exception,
'client.parse_response(ATR, info=jerr, sformat="focus")')