Libraries refactor and add some sinks #4

Closed
m wants to merge 136 commits from library-refactor into master
1 changed files with 5 additions and 6 deletions
Showing only changes of commit df281b6e43 - Show all commits

View File

@ -17,7 +17,8 @@ class Nordigen(object):
def __init__(self):
self.log = Logger("nordigen")
# self.get_access_token()
self.token = None
self.get_access_token()
def get_access_token(self):
"""
@ -38,10 +39,8 @@ class Nordigen(object):
self.log.error("Error parsing access token response: {content}", content=r.content)
return False
if "access" in parsed:
settings.Nordigen.Access = parsed["access"]
settings.write()
print(dumps(self.get_institutions(""), indent=2))
self.token = parsed["access"]
self.log.info("Refreshed access token - Nordigen")
def get_institutions(self, country, filter_name=None):
"""
@ -49,7 +48,7 @@ class Nordigen(object):
"""
if not len(country) == 2:
return False
headers = {"accept": "application/json", "Authorization": f"Bearer {settings.Nordigen.Access}"}
headers = {"accept": "application/json", "Authorization": f"Bearer {self.token}"}
path = f"{settings.Nordigen.Base}/institutions/?country={country}"
r = requests.get(path, headers=headers)
try: