@@ -177,7 +177,7 @@ def do_GET(self):
177
177
self .wfile .write (b'You can close this tab.' )
178
178
179
179
180
- class RefreshableCredentials (Refreshable ):
180
+ class SessionCredentials (Refreshable ):
181
181
182
182
def __init__ (self , client : 'OAuthClient' , token : Token ):
183
183
self ._client = client
@@ -187,8 +187,8 @@ def as_dict(self) -> dict:
187
187
return {'token' : self ._token .as_dict ()}
188
188
189
189
@staticmethod
190
- def from_dict (client : 'OAuthClient' , raw : dict ) -> 'RefreshableCredentials ' :
191
- return RefreshableCredentials (client = client , token = Token .from_dict (raw ['token' ]))
190
+ def from_dict (client : 'OAuthClient' , raw : dict ) -> 'SessionCredentials ' :
191
+ return SessionCredentials (client = client , token = Token .from_dict (raw ['token' ]))
192
192
193
193
def auth_type (self ):
194
194
"""Implementing CredentialsProvider protocol"""
@@ -237,7 +237,7 @@ def as_dict(self) -> dict:
237
237
def from_dict (client : 'OAuthClient' , raw : dict ) -> 'Consent' :
238
238
return Consent (client , raw ['state' ], raw ['verifier' ])
239
239
240
- def launch_external_browser (self ) -> RefreshableCredentials :
240
+ def launch_external_browser (self ) -> SessionCredentials :
241
241
redirect_url = urllib .parse .urlparse (self ._client .redirect_url )
242
242
if redirect_url .hostname not in ('localhost' , '127.0.0.1' ):
243
243
raise ValueError (f'cannot listen on { redirect_url .hostname } ' )
@@ -254,14 +254,14 @@ def launch_external_browser(self) -> RefreshableCredentials:
254
254
query = feedback .pop ()
255
255
return self .exchange_callback_parameters (query )
256
256
257
- def exchange_callback_parameters (self , query : Dict [str , str ]) -> RefreshableCredentials :
257
+ def exchange_callback_parameters (self , query : Dict [str , str ]) -> SessionCredentials :
258
258
if 'error' in query :
259
259
raise ValueError ('{error}: {error_description}' .format (** query ))
260
260
if 'code' not in query or 'state' not in query :
261
261
raise ValueError ('No code returned in callback' )
262
262
return self .exchange (query ['code' ], query ['state' ])
263
263
264
- def exchange (self , code : str , state : str ) -> RefreshableCredentials :
264
+ def exchange (self , code : str , state : str ) -> SessionCredentials :
265
265
if self ._state != state :
266
266
raise ValueError ('state mismatch' )
267
267
params = {
@@ -279,7 +279,7 @@ def exchange(self, code: str, state: str) -> RefreshableCredentials:
279
279
params = params ,
280
280
headers = headers ,
281
281
use_params = True )
282
- return RefreshableCredentials (self ._client , token )
282
+ return SessionCredentials (self ._client , token )
283
283
except ValueError as e :
284
284
if NO_ORIGIN_FOR_SPA_CLIENT_ERROR in str (e ):
285
285
# Retry in cases of 'Single-Page Application' client-type with
@@ -420,7 +420,7 @@ def filename(self) -> str:
420
420
hash .update (chunk .encode ('utf-8' ))
421
421
return os .path .expanduser (os .path .join (self .__class__ .BASE_PATH , hash .hexdigest () + ".json" ))
422
422
423
- def load (self ) -> Optional [RefreshableCredentials ]:
423
+ def load (self ) -> Optional [SessionCredentials ]:
424
424
"""
425
425
Load credentials from cache file. Return None if the cache file does not exist or is invalid.
426
426
"""
@@ -430,11 +430,11 @@ def load(self) -> Optional[RefreshableCredentials]:
430
430
try :
431
431
with open (self .filename , 'r' ) as f :
432
432
raw = json .load (f )
433
- return RefreshableCredentials .from_dict (self .client , raw )
433
+ return SessionCredentials .from_dict (self .client , raw )
434
434
except Exception :
435
435
return None
436
436
437
- def save (self , credentials : RefreshableCredentials ) -> None :
437
+ def save (self , credentials : SessionCredentials ) -> None :
438
438
"""
439
439
Save credentials to cache file.
440
440
"""
0 commit comments