Update oauth access token expiration time
parent
228535e042
commit
0c4908e9b6
|
@ -5,6 +5,7 @@ import logging
|
|||
import os
|
||||
import requests
|
||||
import requests_oauthlib
|
||||
from datetime import datetime
|
||||
|
||||
from mopidy import httpclient, exceptions
|
||||
|
||||
|
@ -147,17 +148,19 @@ def get_token(config):
|
|||
except IOError:
|
||||
return None
|
||||
try:
|
||||
return json.loads(raw)
|
||||
token_data = json.loads(raw)
|
||||
token_data["expires_in"] = token_data["expires_at"] - datetime.timestamp(datetime.now())
|
||||
return token_data
|
||||
except (TypeError, ValueError):
|
||||
logger.error("Cannot decode token data, you may need to relogin")
|
||||
|
||||
|
||||
def set_token(token_data, config):
|
||||
|
||||
|
||||
|
||||
import mopidy_funkwhale
|
||||
|
||||
expires_in = token_data["expires_at"] - datetime.timestamp(datetime.now())
|
||||
token_data["expires_in"] = expires_in
|
||||
|
||||
data_dir = mopidy_funkwhale.Extension.get_data_dir(config)
|
||||
print(data_dir)
|
||||
content = json.dumps(token_data)
|
||||
|
|
Loading…
Reference in New Issue