From b53fbfc90564c0fad689a5b712336670f8956a87 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Fri, 4 Mar 2022 21:06:54 +0000 Subject: [PATCH] Fix TrueLayer --- handler/sinks/truelayer.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/handler/sinks/truelayer.py b/handler/sinks/truelayer.py index 28e7af4..481bf89 100644 --- a/handler/sinks/truelayer.py +++ b/handler/sinks/truelayer.py @@ -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