Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch_token should check the status_code of the response before parsing the result #446

Open
hhowe29 opened this issue May 19, 2021 · 0 comments

Comments

@hhowe29
Copy link

hhowe29 commented May 19, 2021

This block of code should check the status_code of the response before parsing. If the server returns a 403, or any non 2xx code for that matter, then that error should propagate out to the caller. The current code just goes ahead and tries to parse the response text as json. On a 403, the response body is likely to be html

r = self.request(
method=method,
url=token_url,
timeout=timeout,
headers=headers,
auth=auth,
verify=verify,
proxies=proxies,
cert=cert,
**request_kwargs
)
log.debug("Request to fetch token completed with status %s.", r.status_code)
log.debug("Request url was %s", r.request.url)
log.debug("Request headers were %s", r.request.headers)
log.debug("Request body was %s", r.request.body)
log.debug("Response headers were %s and content %s.", r.headers, r.text)
log.debug(
"Invoking %d token response hooks.",
len(self.compliance_hook["access_token_response"]),
)
for hook in self.compliance_hook["access_token_response"]:
log.debug("Invoking hook %s.", hook)
r = hook(r)
self._client.parse_request_body_response(r.text, scope=self.scope)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant