Skip to content

Commit

Permalink
[XK] fix error on setting authorization cookie (#14)
Browse files Browse the repository at this point in the history
fix `AttributeError: 'LWPCookieJar' object has no attribute 'update'`
this error only occurs for log-ins with CAPTCHA prompted.
  • Loading branch information
Pairman authored Jun 14, 2024
1 parent b1cf205 commit 4a33375
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libxduauth/sites/xk.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ def __init__(self, username, password, keyword=''):
self.user['electiveBatchList']
))
self.persist('batch', json.dumps(self.current_batch))
cookies = requests.utils.dict_from_cookiejar(self.cookies)
self.cookies.update({'Authorization': cookies['token']})
cookie_token = next(c for c in self.cookies if c.name == "token")
self.persist("Authorization", cookie_token.value)
self.get(self.BASE + '/elective/grablessons', params={
'batchId': self.current_batch['code'],
}) # wierd, yet mandatory.
self.headers.update({'Authorization': cookies['token']})
self.headers.update({'Authorization': cookie_token.value})

def persist(self, name, value):
self.cookies.set_cookie(requests.cookies.create_cookie(
Expand Down

0 comments on commit 4a33375

Please sign in to comment.