(self, status_code, text)
| 153 | return token |
| 154 | |
| 155 | def parse_response_token(self, status_code, text): |
| 156 | if status_code >= 400: |
| 157 | message = ( |
| 158 | f"Token request failed with code {status_code}, response was '{text}'." |
| 159 | ) |
| 160 | self.handle_error("fetch_token_denied", message) |
| 161 | |
| 162 | try: |
| 163 | text = text.strip() |
| 164 | if text.startswith("{"): |
| 165 | token = json_loads(text) |
| 166 | else: |
| 167 | token = dict(url_decode(text)) |
| 168 | except (TypeError, ValueError) as e: |
| 169 | error = ( |
| 170 | "Unable to decode token from token response. " |
| 171 | "This is commonly caused by an unsuccessful request where" |
| 172 | " a non urlencoded error message is returned. " |
| 173 | f"The decoding error was {e}" |
| 174 | ) |
| 175 | raise ValueError(error) from e |
| 176 | return token |
| 177 | |
| 178 | @staticmethod |
| 179 | def handle_error(error_type, error_description): |
no test coverage detected