File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010from trakt import errors
1111from trakt .config import AuthConfig
1212from trakt .core import TIMEOUT
13- from trakt .errors import BadResponseException , OAuthException
13+ from trakt .errors import BadRequestException , BadResponseException , OAuthException
1414
1515__author__ = 'Elan Ruusamäe'
1616
@@ -249,10 +249,20 @@ def refresh_token(self):
249249 try :
250250 response = self .client .post ('oauth/token' , data )
251251 self .refresh_attempts = 0
252- except OAuthException :
253- self .logger .debug (
254- "Rejected - Unable to refresh expired OAuth token, "
255- "refresh_token is invalid"
252+ except (OAuthException , BadRequestException ) as e :
253+ if e .response is not None :
254+ try :
255+ error = e .response .json ().get ("error" )
256+ error_description = e .response .json ().get ("error_description" )
257+ except JSONDecodeError :
258+ error = "Invalid JSON response"
259+ error_description = e .response .text
260+ else :
261+ error = "No error description"
262+ error_description = ""
263+ self .logger .error (
264+ "%s - Unable to refresh expired OAuth token (%s) %s" ,
265+ e .http_code , error , error_description
256266 )
257267 return
258268
You can’t perform that action at this time.
0 commit comments