My project will consist of two parts, one that will fetch my Magister bearer token and one that will fetch my calendar.
The first part will use a managed browser to go to Magister, enter my credentials it fetched from credentials.json, and then listen for a network request containing my token (see video). Also, sorry for the giant watermark, I was at school and only have a Chromebook. The token, along with my user_id, is then saved again to credentials.json (see image).
The second piece of code then uses this token to make a request to Magister, the url for this looks like this (translated from Dutch):
/api/people/{user_id}/appointments?status=1&until={end_date}&from={begin_date}
For now I have just hard-coded the end date, but I plan on making it dynamic using datetime. The output of this request is a gigantic mess, it contains so many duplicate entries and irrelevant data. Luckily I already did some work before this project, so I can roughly show my schedule I got (see image). This schedule shows the lesson hour, the subject, the teacher, the class, and then the classroom number.
This output looks like a mess and is far from standardised. I plan on using ical to format my whole agenda, this is going to take a whole lot of work.
Also, the end goals is making this a Home Assistant add-on, so I will also have to make this a loop that checks when the token needs to be refreshed and fetches my calendar and hosts it on a local port. I think this would be the cleanest way. The calendar could then be added again in Home Assistant.