Skip to content

Server says "Forbidden" when creating event with timezone #372

@seanmills1020

Description

@seanmills1020

Hello,

I am new to Python, so I feel like I am making a silly mistake.

I am trying to add an event to my calendar. The following code works:

from datetime import datetime
import caldav


with caldav.DAVClient(url=CALENDAR_SERVER_URL, username=USERNAME, password=PASSWORD,
                      ssl_verify_cert=False) as client:

    calendar = client.calendar(url=USER_CALENDAR_URL)
    timestamp_start = datetime(year=2024, month=1, day=26, hour=18, minute=0, second=0)
    timestamp_end = datetime(year=2024, month=1, day=26, hour=18, minute=30, second=0)

    new_event = calendar.save_event(
        dtstart=timestamp_start,
        dtend=timestamp_end,
        summary="Sean's Comedy Debut"
    )

However, if I add a tzinfo argument, I get an error.

from datetime import datetime
from dateutil import tz
import caldav


with caldav.DAVClient(url=CALENDAR_SERVER_URL, username=USERNAME, password=PASSWORD,
                      ssl_verify_cert=False) as client:

    calendar = client.calendar(url=USER_CALENDAR_URL)
    timezone = tz.gettz("America/Los_Angeles")
    timestamp_start = datetime(year=2024, month=1, day=26, hour=18, minute=0, second=0, tzinfo=timezone)
    timestamp_end = datetime(year=2024, month=1, day=26, hour=18, minute=30, second=0, tzinfo=timezone)

    new_event = calendar.save_event(
        dtstart=timestamp_start,
        dtend=timestamp_end,
        summary="Sean's Comedy Debut"
    )

The last part of the traceback is:
caldav.lib.error.AuthorizationError: AuthorizationError at '<some_url>', reason Forbidden

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions