Skip to content

Commit 460521c

Browse files
committed
Adding refresh_token_request hook
1 parent 46f886c commit 460521c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

requests_oauthlib/oauth2_session.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def __init__(
9595
"access_token_response": set(),
9696
"refresh_token_response": set(),
9797
"protected_request": set(),
98+
"refresh_token_request": set(),
9899
}
99100

100101
def new_state(self):
@@ -429,6 +430,10 @@ def refresh_token(
429430
"Content-Type": ("application/x-www-form-urlencoded;charset=UTF-8"),
430431
}
431432

433+
for hook in self.compliance_hook["refresh_token_request"]:
434+
log.debug("Invoking refresh_token_request hook %s.", hook)
435+
token_url, headers, body = hook(token_url, headers, body)
436+
432437
r = self.post(
433438
token_url,
434439
data=dict(urldecode(body)),
@@ -529,6 +534,7 @@ def register_compliance_hook(self, hook_type, hook):
529534
access_token_response invoked before token parsing.
530535
refresh_token_response invoked before refresh token parsing.
531536
protected_request invoked before making a request.
537+
refresh_token_request invoked before making a refresh request.
532538
533539
If you find a new hook is needed please send a GitHub PR request
534540
or open an issue.

0 commit comments

Comments
 (0)