franc6 / ics_calendar

Provides an ICS (icalendar) platform for the Home Assistant calendar
Apache License 2.0
128 stars 19 forks source link

403 error with access token #106

Closed Pka78 closed 8 months ago

Pka78 commented 8 months ago

Hi, i'm trying to import my kids school timetable to HA with this integration. Address to ICS file does contain token, and with that token ICS file is in readable conditions. But it kinda seems that ics_calendar integration forgets everything after ? mark and so result is unauthorized.

Source address is like: https://turku.inschool.fi/schedule/export/students/578261/Wilma.ics?token=7bBf0NvZx3dH2aRiLqTmG1YyWlXp6S8KjUoA9E5eIcP4sJrQ

ICS_Calendar logs: This error originated from a custom integration.

Logger: custom_components.ics_calendar.calendar Source: custom_components/ics_calendar/calendardata.py:173 Integration: ics Calendar (documentation, issues) First occurred: 17:17:45 (2 occurrences) Last logged: 17:18:45

Wilhelmiinan lukujärjestys: Failed to open url(https://turku.inschool.fi/schedule/export/students/306731/Wilma.ics): Forbidden Wernerin lukujärjestys: Failed to open url(https://turku.inschool.fi/schedule/export/students/341804/Wilma.ics?token=tokennumber): Forbidden

I tried to use my username and password for the 1:st one, but that doesn't work. That's quite obious because that is "Wilma" system.

NOTE: Student id and token is mixed so please, don't try this address.

jurasjo commented 8 months ago

Hi, I use this calendar with this kind of configuration and it works:

  calendars:
      - name: "Wilma"
        url: "https://turku.inschool.fi/schedule/export/students/578261/Wilma.ics?token=7bBf0NvZx3dH2aRiLqTmG1YyWlXp6S8KjUoA9E5eIcP4sJrQ&tstamp=1677564430"
        days: 31
        download_interval: 60
        include_all_day: True
        user_agent: "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0"

Have you removed the last part of the address which contains timestamp? eg &tstamp=1677564430

I think it might be a reason. I also declare user agent. If I remember correctly, I used to have problems without it. Another thing is, Wilma is often not accessible... Wilma is Wilma ;)

Pka78 commented 8 months ago

That address is accesible trough same computer with CURL and wget and yeah, i have. It really doesn't need after: & mark in tstamp information. It's pretty much accessible without it. I'll try to add user_agent to sync line - let's see how that one works.

Pka78 commented 8 months ago

User agent resolved this issue, thanks.

lordfiSh commented 1 month ago

Can confirm, I had to add Useragent else I get a Forbidden