From 3aee98f1403e6126e22e673ddbe52a44d6c86e58 Mon Sep 17 00:00:00 2001 From: Matthias Michel Date: Mon, 6 Nov 2023 18:13:30 +0100 Subject: [PATCH] fix(authentication): switch authentication mode Description: - function fails with `{'message': 'Not authenticated'}` - move to different headers and authentication solves the problem Steps to reproduce: - Demo code, modify uid_to_update, username and password ```` import asyncio from config import password, username from spond import spond async def main(): s = spond.Spond(username=username, password=password) uid_to_update = "xxxxxxxxxxx" updates = { 'heading': "print", 'description': "New Description with changes", # Add other updates as needed } try: await s.update_event(uid_to_update, updates) print("Event updated successfully.") except Exception as e: print(f"Failed to update event: {e}") await s.clientsession.close() loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) asyncio.run(main()) ```` Expected behavier: - authentication is successful --- spond/spond.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spond/spond.py b/spond/spond.py index d342f3e..b95f3a9 100644 --- a/spond/spond.py +++ b/spond/spond.py @@ -376,7 +376,8 @@ async def update_event(self, uid, updates: dict): base_event[key] = updates[key] data = dict(base_event) - headers = {"content-type": "application/json;charset=utf-8"} - async with self.clientsession.post(url, json=data, headers=headers) as r: + async with self.clientsession.post( + url, json=data, headers=self.auth_headers + ) as r: self.events_update = await r.json() return self.events