本文整理汇总了Python中oic.oic.message.AccessTokenResponse.to_dict方法的典型用法代码示例。如果您正苦于以下问题:Python AccessTokenResponse.to_dict方法的具体用法?Python AccessTokenResponse.to_dict怎么用?Python AccessTokenResponse.to_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oic.oic.message.AccessTokenResponse
的用法示例。
在下文中一共展示了AccessTokenResponse.to_dict方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parse_access_token_response_missing_attribute
# 需要导入模块: from oic.oic.message import AccessTokenResponse [as 别名]
# 或者: from oic.oic.message.AccessTokenResponse import to_dict [as 别名]
def test_parse_access_token_response_missing_attribute():
at = AccessTokenResponse(access_token="SlAV32hkKG", token_type="Bearer",
refresh_token="8xLOxBtZp8", expires_in=3600)
atdict = at.to_dict()
del atdict["access_token"]
atj = json.dumps(atdict)
print atj
client = Client()
ATR = AccessTokenResponse
raises(MissingRequiredAttribute, "client.parse_response(ATR, info=atj)")
atuec = urllib.urlencode(atdict)
raises(MissingRequiredAttribute,
"client.parse_response(ATR, info=atuec, sformat='urlencoded')")
示例2: _refresh_access_token_endpoint
# 需要导入模块: from oic.oic.message import AccessTokenResponse [as 别名]
# 或者: from oic.oic.message.AccessTokenResponse import to_dict [as 别名]
def _refresh_access_token_endpoint(self, req, **kwargs):
_sdb = self.sdb
_log_debug = logger.debug
client_info = self.cdb[req["client_id"]]
assert req["grant_type"] == "refresh_token"
rtoken = req["refresh_token"]
_info = _sdb.refresh_token(rtoken)
if "openid" in _info["scope"]:
userinfo = self.userinfo_in_id_token_claims(_info)
_idtoken = self.sign_encrypt_id_token(_info, client_info, req,
user_info=userinfo)
sid = _sdb.token.get_key(rtoken)
_sdb.update(sid, "id_token", _idtoken)
_log_debug("_info: %s" % _info)
atr = AccessTokenResponse(**by_schema(AccessTokenResponse, **_info))
_log_debug("access_token_response: %s" % atr.to_dict())
return Response(atr.to_json(), content="application/json")
示例3: _log_debug
# 需要导入模块: from oic.oic.message import AccessTokenResponse [as 别名]
# 或者: from oic.oic.message.AccessTokenResponse import to_dict [as 别名]
if "openid" in _info["scope"]:
try:
_idtoken = self._id_token(_info)
except AccessDenied:
return self._error(environ, start_response,
error="access_denied")
_sdb.update_by_token(_access_code, "id_token", _idtoken)
_log_debug("_tinfo: %s" % _tinfo)
atr = AccessTokenResponse(**by_schema(AccessTokenResponse, **_tinfo))
if self.test_mode:
_log_info("access_token_response: %s" % atr.to_dict())
resp = Response(atr.to_json(), content="application/json")
return resp(environ, start_response)
def _bearer_auth(self, environ):
#'HTTP_AUTHORIZATION': 'Bearer pC7efiVgbI8UASlolltdh76DrTZ2BQJQXFhVvwWlKekFvWCcdMTmNCI/BCSCxQiG'
try:
authn = environ["HTTP_AUTHORIZATION"]
try:
assert authn[:6].lower() == "bearer"
_token = authn[7:]
except AssertionError:
raise AuthnFailure("AuthZ type I don't know")
except KeyError:
raise AuthnFailure
示例4: _log_debug
# 需要导入模块: from oic.oic.message import AccessTokenResponse [as 别名]
# 或者: from oic.oic.message.AccessTokenResponse import to_dict [as 别名]
logger.error("%s" % err)
# Should revoke the token issued to this access code
_sdb.revoke_all_tokens(_access_code)
return self._error(error="access_denied", descr="%s" % err)
if "openid" in _info["scope"]:
userinfo = self.userinfo_in_id_token_claims(_info)
_idtoken = self.sign_encrypt_id_token(_info, client_info, req,
user_info=userinfo)
_sdb.update_by_token(_access_code, "id_token", _idtoken)
_log_debug("_tinfo: %s" % _tinfo)
atr = AccessTokenResponse(**by_schema(AccessTokenResponse, **_tinfo))
_log_debug("access_token_response: %s" % atr.to_dict())
return Response(atr.to_json(), content="application/json")
def _refresh_access_token_endpoint(self, req, **kwargs):
_sdb = self.sdb
_log_debug = logger.debug
client_info = self.cdb[req["client_id"]]
assert req["grant_type"] == "refresh_token"
rtoken = req["refresh_token"]
_info = _sdb.refresh_token(rtoken)
if "openid" in _info["scope"]:
userinfo = self.userinfo_in_id_token_claims(_info)