Commit 05290fdb authored by Luciano Cauzzi's avatar Luciano Cauzzi

Added autologin function

parent 82982b23
......@@ -19,6 +19,7 @@ class AppPyramidManager:
"Initialization completed: \nBASE_URL= {} \nRESOURCE_URL= {}\nAPI_KEY= {}".format(base_url, resource_url,
def login(self) -> Optional[AppToken]:
......@@ -31,6 +32,7 @@ class AppPyramidManager:
response =, data=payload, headers=headers, timeout=AppPyramidManager.TIMEOUT)
json_repr = json.loads(response.text)
self.__app_token__ = app_token_from_dict(json_repr)"User has been authenticated")
return self.__app_token__
except Exception as e:
logger.error("Error while authenticating into pyramid {} \n".format(e))
......@@ -98,6 +100,8 @@ class AppPyramidManager:
return True
def __get_auth_header__(self):
if self.__app_token__ is None:
raise Exception("User should be authenticated")
return {
'AUTHORIZATION': self.__app_token__.token,
'Content-Type': "application/json"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment