Save credential when logging in

This commit is contained in:
Gabriel Augendre 2020-11-18 15:41:14 +01:00
parent 919d6c2523
commit 22b9f53dfb
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4

View file

@ -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):