Fix TrueLayer
This commit is contained in:
parent
88e87e53d5
commit
b53fbfc905
|
@ -1,5 +1,6 @@
|
||||||
# Twisted/Klein imports
|
# Twisted/Klein imports
|
||||||
from twisted.logger import Logger
|
from twisted.logger import Logger
|
||||||
|
from twisted.internet.task import LoopingCall
|
||||||
|
|
||||||
# Other library imports
|
# Other library imports
|
||||||
import requests
|
import requests
|
||||||
|
@ -19,6 +20,8 @@ class TrueLayer(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.log = Logger("truelayer")
|
self.log = Logger("truelayer")
|
||||||
self.token = None
|
self.token = None
|
||||||
|
self.lc = LoopingCall(self.get_new_token)
|
||||||
|
self.lc.start(int(settings.TrueLayer.RefreshSec))
|
||||||
|
|
||||||
def setup_auth(self):
|
def setup_auth(self):
|
||||||
pass
|
pass
|
||||||
|
@ -101,13 +104,12 @@ class TrueLayer(object):
|
||||||
Get a list of accounts.
|
Get a list of accounts.
|
||||||
"""
|
"""
|
||||||
headers = {"Authorization": f"Bearer {self.token}"}
|
headers = {"Authorization": f"Bearer {self.token}"}
|
||||||
# path = f"{settings.TrueLayer.DataBase}/accounts"
|
path = f"{settings.TrueLayer.DataBase}/accounts"
|
||||||
path = "https://api.truelayer-sandbox.com/data/v1/accounts"
|
|
||||||
r = requests.get(path, headers=headers)
|
r = requests.get(path, headers=headers)
|
||||||
try:
|
try:
|
||||||
parsed = r.json()
|
parsed = r.json()
|
||||||
except JSONDecodeError:
|
except JSONDecodeError:
|
||||||
self.log.error("Error parsing institutions response: {content}", content=r.content)
|
self.log.error("Error parsing institutions response: {content}", content=r.content)
|
||||||
return False
|
return False
|
||||||
print("GET ACCOUNTS", parsed)
|
|
||||||
return parsed
|
return parsed
|
||||||
|
|
Loading…
Reference in New Issue