Fix TrueLayer

This commit is contained in:
Mark Veidemanis 2022-03-04 21:06:54 +00:00
parent 88e87e53d5
commit b53fbfc905
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 5 additions and 3 deletions

View File

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