Olen/Spond

function update_event fails with error

Closed this issue · 2 comments

Description:

  • function fails with {'message': 'Not authenticated'}

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

Working Solution:

  • change header in function update_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:

Olen commented

Would you be able to create a PR?