gracefully fail refreshing tokens
This commit is contained in:
+12
-8
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from datetime import datetime,timezone
|
from datetime import datetime,timezone
|
||||||
from urllib.parse import quote_plus
|
from urllib.parse import quote_plus
|
||||||
from urllib.request import urlretrieve, urlopen, Request
|
from urllib.request import urlretrieve, urlopen, Request, HTTPError
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from os import makedirs,path
|
from os import makedirs,path
|
||||||
import json,sys,webbrowser,importlib
|
import json,sys,webbrowser,importlib
|
||||||
@@ -172,13 +172,17 @@ def refresh_tokens(refresh_token):
|
|||||||
).encode(),
|
).encode(),
|
||||||
{'Content-Type':'application/x-www-form-urlencoded'}
|
{'Content-Type':'application/x-www-form-urlencoded'}
|
||||||
)
|
)
|
||||||
refresh_response=urlopen(refresh_request)
|
try:
|
||||||
refresh_response=json.loads(refresh_response.read())
|
refresh_response=urlopen(refresh_request)
|
||||||
save_tokens(refresh_response['access_token'],refresh_response['refresh_token'])
|
refresh_response=json.loads(refresh_response.read())
|
||||||
return{
|
save_tokens(refresh_response['access_token'],refresh_response['refresh_token'])
|
||||||
'access_token':refresh_response['access_token'],
|
return{
|
||||||
'refresh_token':refresh_response['refresh_token'],
|
'access_token':refresh_response['access_token'],
|
||||||
}
|
'refresh_token':refresh_response['refresh_token'],
|
||||||
|
}
|
||||||
|
except HTTPError:
|
||||||
|
print('refreshing tokens failed')
|
||||||
|
return {}
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
from twitch import Client
|
from twitch import Client
|
||||||
|
|||||||
Reference in New Issue
Block a user