def parse_response_challenge(self, response, **kwargs): """Modifies prepared request so challenge can be sent to login :param: requests.PreparedRequest response prepared request :return: Modified prepared request :rtype: requests.PreparedRequest :raises AuthenticationError: if application response isn't valid """ app_response = ApplicationResponse(response) try: app_response.raise_for_status() except ApplicationError: log.error("receive_authentication_token(): login failed: %r" % app_response.data) raise AuthenticationError() self.populate_token_attributes(app_response) log.debug("receive_authentication_token(): got token: %s", self._authentication_token) return response
def parse_response_verify(self, response, **kwargs): """Process response from verify call This is last step to be able to use token to authenticate. :param: requests.Response response Response to process. :return: Same response that was used as parameter :rtype: requests.Response :raises AuthenticationError: if application response isn't valid """ app_response = ApplicationResponse(response) try: app_response.raise_for_status() except ApplicationError: log.error("receive_authentication_token(): verify failed") return AuthenticationError() self._challenge_response = None self.authentication_token = self._authentication_token self._authentication_token = None return response