@@ -418,6 +418,15 @@ def refresh_token(
418
418
"Adding auto refresh key word arguments %s." , self .auto_refresh_kwargs
419
419
)
420
420
kwargs .update (self .auto_refresh_kwargs )
421
+
422
+ auth = auth or kwargs .pop ('auth' , None )
423
+ client_id = kwargs .get ('client_id' )
424
+ client_secret = kwargs .get ('client_secret' , '' )
425
+
426
+ if client_id and (auth is None ):
427
+ log .debug ('Encoding client_id "%s" with client_secret as Basic auth credentials.' , client_id )
428
+ auth = requests .auth .HTTPBasicAuth (client_id , client_secret )
429
+
421
430
body = self ._client .prepare_refresh_body (
422
431
body = body , refresh_token = refresh_token , scope = self .scope , ** kwargs
423
432
)
@@ -491,16 +500,9 @@ def request(
491
500
self .auto_refresh_url ,
492
501
)
493
502
494
- # We mustn't pass auth twice.
495
- auth = kwargs .pop ("auth" , None )
496
- if client_id and client_secret and (auth is None ):
497
- log .debug (
498
- 'Encoding client_id "%s" with client_secret as Basic auth credentials.' ,
499
- client_id ,
500
- )
501
- auth = requests .auth .HTTPBasicAuth (client_id , client_secret )
502
503
token = self .refresh_token (
503
- self .auto_refresh_url , auth = auth , ** kwargs
504
+ self .auto_refresh_url , client_id = client_id ,
505
+ client_secret = client_secret , ** kwargs
504
506
)
505
507
if self .token_updater :
506
508
log .debug (
0 commit comments