Add logging?
requests_oauth2clientversion: 1.6.0- Python version: 3.12.8
- Operating System: macOS 15.3
Description
Hi! First off, thank you so much for building and maintaining requests_oauth2client. It's great!
I'm debugging an UnknownTokenEndpointError right now, and my first instinct was to turn on requests_oauth2client's logging so that I could see the full HTTP requests and responses...but there isn't any logging yet. Any chance you might consider adding some? It'd be a huge help for debugging like this.
Thanks in advance!
Found how to enable logging at the requests level, that takes some of the pressure off here: https://requests.readthedocs.io/en/latest/api/#:~:text=be%20handled%20by-,configuring%20logging
Thanks for the feedback! I might add logging at some point, but PRs are welcome :)
If you get a UnknownTokenEndpointError , that means the AS sends back an error code that does not have a dedicated exception class. You can see that error and error_description in corresponding attributes of the error. I added most of the standard ones from https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml a while back, but some new ones probably have popped since then. I'll check that. Or it might be a non-standard error code.
You also have access to the Request and Response instances as attributes of that exception, e.g. like this:
try:
oauth2client.client_credentials() # or whatever other way you send the token request
except EndpointError as exc:
print(f"{exc.error}: {exc.description}")
print(exc.response.status_code, exc.response.reason)
for header, value in exc.response.headers.items():
print(f"{header}: {value}")
print(exc.response.text)
Let me know if that helps you identify your issue.
Did you find which error code your AS was returning ? And is your issue solved?
Hi! I did figure this one out and get past it, but I don't remember the root cause, sorry.