@@ -462,6 +462,7 @@ def __init__(self,
462
462
def _obtain_token (
463
463
self , grant_type , params = None , data = None ,
464
464
also_save_rt = False ,
465
+ on_obtaining_tokens = None ,
465
466
* args , ** kwargs ):
466
467
_data = data .copy () # to prevent side effect
467
468
resp = super (Client , self )._obtain_token (
@@ -481,7 +482,7 @@ def _obtain_token(
481
482
# but our obtain_token_by_authorization_code(...) encourages
482
483
# app developer to still explicitly provide a scope here.
483
484
scope = _data .get ("scope" )
484
- self .on_obtaining_tokens ({
485
+ ( on_obtaining_tokens or self .on_obtaining_tokens ) ({
485
486
"client_id" : self .client_id ,
486
487
"scope" : scope ,
487
488
"token_endpoint" : self .configuration ["token_endpoint" ],
@@ -495,6 +496,7 @@ def obtain_token_by_refresh_token(self, token_item, scope=None,
495
496
rt_getter = lambda token_item : token_item ["refresh_token" ],
496
497
on_removing_rt = None ,
497
498
on_updating_rt = None ,
499
+ on_obtaining_tokens = None ,
498
500
** kwargs ):
499
501
# type: (Union[str, dict], Union[str, list, set, tuple], Callable) -> dict
500
502
"""This is an overload which will trigger token storage callbacks.
0 commit comments