def parse_authz_response(self, query): aresp = self.parse_response(AuthorizationResponse, info=query, sformat="urlencoded", keyjar=self.keyjar) if aresp.type() == "ErrorResponse": logger.info("ErrorResponse: %s" % aresp) raise AuthzError(aresp.error) logger.info("Aresp: %s" % aresp) return aresp
def handle_authorization_response(self, query="", **kwargs): """ This is where we get redirect back to after authorization at the authorization server has happened. :param query: The query part of the request :return: A AccessTokenResponse instance """ logger.debug("- authorization - %s flow -" % self.flow_type) logger.debug("QUERY: %s" % sanitize(query)) if "code" in self.response_type: # Might be an error response try: aresp = self.parse_response(AuthorizationResponse, info=query, sformat="urlencoded") except Exception as err: logger.error("%s" % err) raise if isinstance(aresp, Message): if aresp.type().endswith("ErrorResponse"): raise AuthzError(aresp["error"]) try: self.update(aresp["state"]) except KeyError: raise UnknownState(aresp["state"]) self._backup(aresp["state"]) return aresp else: # implicit flow atr = self.parse_response(AccessTokenResponse, info=query, sformat="urlencoded", extended=True) if isinstance(atr, Message): if atr.type().endswith("ErrorResponse"): raise TokenError(atr["error"]) try: self.update(atr["state"]) except KeyError: raise UnknownState(atr["state"]) self.seed = self.grant[atr["state"]].seed return atr
def parse_authz_response(self, query): aresp = self.parse_response( self.message_factory.get_response_type("authorization_endpoint"), info=query, sformat="urlencoded", keyjar=self.keyjar, ) if aresp.type() == "ErrorResponse": logger.info("ErrorResponse: %s" % sanitize(aresp)) raise AuthzError(aresp.error) logger.info("Aresp: %s" % sanitize(aresp)) return aresp
def parse_authz_response(self, query): aresp = self.parse_response( self.message_factory.get_response_type("authorization_endpoint"), info=query, sformat="urlencoded", keyjar=self.keyjar, ) if isinstance(aresp, ErrorResponse): logger.info("ErrorResponse: %s" % sanitize(aresp)) raise AuthzError( aresp.error # type: ignore # Messages have no classical attrs ) logger.info("Aresp: %s" % sanitize(aresp)) return aresp
def _parse_authz(self, query="", **kwargs): _log_info = logger.info # Might be an error response _log_info("Expect Authorization Response") aresp = self.parse_response( AuthorizationResponse, info=query, sformat="urlencoded", keyjar=self.keyjar ) if isinstance(aresp, ErrorResponse): _log_info("ErrorResponse: %s" % sanitize(aresp)) raise AuthzError(aresp.get("error"), aresp) _log_info("Aresp: %s" % sanitize(aresp)) _state = aresp["state"] try: self.update(_state) except KeyError: raise UnknownState(_state, aresp) self.redirect_uris = [self.sdb[_state]["redirect_uris"]] return aresp, _state