def login(self, username, password): self.get(kaurl("login")).raise_for_status() # I'm a little unclear about the nature of KA fkeys, but you can # recieve them by going to /login and they seem to persist throughout # the session - at least I hope so! fkey = self.headers["x-ka-fkey"] = self.cookies["fkey"] self.post(kaurl("login"), data={ "identifier": username, "password": password, "fkey": fkey }).raise_for_status() self.user = User(self.user_id)
def user_id(self): """ Gets the user id of the logged in user """ # api/v1/user gives info on the authorized user by default resp = self.get(kaurl("api/v1/user")) resp.raise_for_status() return resp.json()["kaid"]