File tree Expand file tree Collapse file tree 2 files changed +26
-6
lines changed Expand file tree Collapse file tree 2 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -419,12 +419,15 @@ def refresh_token(
419419 )
420420 kwargs .update (self .auto_refresh_kwargs )
421421
422- auth = auth or kwargs .pop (' auth' , None )
423- client_id = kwargs .get (' client_id' )
424- client_secret = kwargs .get (' client_secret' , '' )
422+ auth = auth or kwargs .pop (" auth" , None )
423+ client_id = kwargs .get (" client_id" )
424+ client_secret = kwargs .get (" client_secret" , "" )
425425
426426 if client_id and (auth is None ):
427- log .debug ('Encoding client_id "%s" with client_secret as Basic auth credentials.' , client_id )
427+ log .debug (
428+ 'Encoding client_id "%s" with client_secret as Basic auth credentials.' ,
429+ client_id ,
430+ )
428431 auth = requests .auth .HTTPBasicAuth (client_id , client_secret )
429432
430433 body = self ._client .prepare_refresh_body (
@@ -501,8 +504,10 @@ def request(
501504 )
502505
503506 token = self .refresh_token (
504- self .auto_refresh_url , client_id = client_id ,
505- client_secret = client_secret , ** kwargs
507+ self .auto_refresh_url ,
508+ client_id = client_id ,
509+ client_secret = client_secret ,
510+ ** kwargs
506511 )
507512 if self .token_updater :
508513 log .debug (
Original file line number Diff line number Diff line change @@ -194,6 +194,21 @@ def fake_refresh_with_auth(r, **kwargs):
194194 client_secret = self .client_secret ,
195195 )
196196
197+ # auto refresh with auth from auto_refresh_kwargs
198+ for client in self .clients :
199+ sess = OAuth2Session (
200+ client = client ,
201+ token = self .expired_token ,
202+ auto_refresh_url = "https://i.b/refresh" ,
203+ token_updater = token_updater ,
204+ auto_refresh_kwargs = {
205+ "client_id" : self .client_id ,
206+ "client_secret" : self .client_secret ,
207+ },
208+ )
209+ sess .send = fake_refresh_with_auth
210+ sess .get ("https://i.b" )
211+
197212 @mock .patch ("time.time" , new = lambda : fake_time )
198213 def test_token_from_fragment (self ):
199214 mobile = MobileApplicationClient (self .client_id )
You can’t perform that action at this time.
0 commit comments