Repository navigation
Adding refresh_token_request and access_token_request compliance hooks - #433
Conversation
|
An example of a large public application that needs Basic Auth for the refresh tokens is the Xero API: https://developer.xero.com/documentation/oauth2/auth-flow#refresh |
|
I've just also added support for an I know this is against the Oauth2 specs, but that's the whole point of compliant hooks 😉 Here's an example usage: def redacted_company_compliance_fix(session):
def _request_in_json_not_form_urlencoded(url, headers, request_kwargs):
headers["Content-Type"] = "application/json"
if "redirect_uri" in request_kwargs["data"]:
del request_kwargs["data"]["redirect_uri"]
request_kwargs["json"] = request_kwargs["data"]
del request_kwargs["data"]
return url, headers, request_kwargs
session.register_compliance_hook("access_token_request", _request_in_json_not_form_urlencoded)
return session |
|
@jtroussard would be please be possible for this to be reviewed? I think it will help in lots of incompliant situations. Thank you 🙏 |
JonathanHuot
left a comment
There was a problem hiding this comment.
Would it be possible to add at least a unit test? This feature is a great addition, so thanks for the extra work.
|
@JonathanHuot I've added a test now for both of the new hooks. Thanks. |
|
Can you execute |
|
Both are sorted now, thanks. |
|
Thanks for this useful feature! |
|
@JonathanHuot would you please be able to make a release on PyPI for this so that we can switch our package manager over to the main project again? Thank you. |
|
Any chance of that PyPI release? 😉 |
|
Hi @violuke, I will prepare a release this month. Thanks for your patience. |
This is based upon #214, so thanks to @jimcortez for basically solving this for me 👍 🙏
We needed this for a custom internal OAuth solution hence no included compliance fix example.
This solved the problem we're having and I believe will solve some or all of the points in issues #182, #379, #430 and #264 so should be useful for the wider community, despite not including a specific compliance fix example.
Here's our internal compliance fix:
I hope this helps someone else, thanks again to @jimcortez for the original work and if this could be merged soon that would be much appreciated. 👍