MCPcopy
hub / github.com/authlib/authlib / parse_response_token

Method parse_response_token

authlib/oauth1/client.py:155–176  ·  view source on GitHub ↗
(self, status_code, text)

Source from the content-addressed store, hash-verified

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):

Callers 1

_fetch_tokenMethod · 0.95

Calls 3

handle_errorMethod · 0.95
json_loadsFunction · 0.90
url_decodeFunction · 0.90

Tested by

no test coverage detected