MCPcopy Create free account
hub / github.com/authlib/authlib / _load_token_response

Function _load_token_response

authlib/oauth2/client.py:20–39  ·  view source on GitHub ↗

Return the JSON object of a token endpoint response. Raise the HTTP error of the response when its body is not a JSON object, such as a rate-limit page from a gateway.

(resp)

Source from the content-addressed store, hash-verified

18
19
20def _load_token_response(resp):
21 """Return the JSON object of a token endpoint response.
22
23 Raise the HTTP error of the response when its body is not a JSON object,
24 such as a rate-limit page from a gateway.
25 """
26 if resp.status_code >= 500:
27 resp.raise_for_status()
28
29 try:
30 token = resp.json()
31 except ValueError:
32 token = None
33
34 if not isinstance(token, dict):
35 resp.raise_for_status()
36 raise ValueError(
37 f"Token endpoint response is not a JSON object (HTTP {resp.status_code})."
38 )
39 return token
40
41
42class OAuth2Client:

Callers 2

parse_response_tokenMethod · 0.90
parse_response_tokenMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected