From 22b9f53dfb79410749e6e3452e03f396c403dd7f Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Wed, 18 Nov 2020 15:41:14 +0100 Subject: [PATCH] Save credential when logging in --- main.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 316a52b..008b9ee 100644 --- a/main.py +++ b/main.py @@ -21,6 +21,7 @@ def main(): class PCloudClient: def __init__(self): self.session = requests.Session() + self.auth = None def login(self): digest = self.get_digest() @@ -28,7 +29,7 @@ class PCloudClient: email_sha = self._sha1(PCLOUD_USER_EMAIL.lower()) logger.debug("email_sha: %s", email_sha) password_digest = self._sha1(PCLOUD_USER_PASSWORD + email_sha + digest) - return self._get( + res = self._get( "/userinfo", params={ "getauth": 1, @@ -37,10 +38,11 @@ class PCloudClient: "passworddigest": password_digest, }, ) + self.auth = res["auth"] + return res def get_digest(self): return self._get("/getdigest").get("digest") - return data.get("digest") @staticmethod def _sha1(string):