devedmonton / DES-Website

The Dev Edmonton Society website! We empower Edmonton Developers!
https://devedmonton.com
MIT License
22 stars 52 forks source link

API Endpoint for Events to be listed on the website /api/events #343

Closed dgmouris closed 3 months ago

dgmouris commented 3 months ago

What issue is this referencing?

This hopefully going to enable us to manage one google calendar and have ability to list those events so that we can see them on the website, which is the original issue referenced https://github.com/devedmonton/DES-Website/issues/312.

This requires and google service account that has permissions to "Make Changes to Events" in the user's google calendar account. Documentation for this will be added shortly.

It also introduces new environment variables that kind of look like this based on the working example shown below. image

Hopefully someone can help me get some credentials for a DES email that probably has all of these events so that I can double check the environment variables locally.

Do these code changes work locally and have you tested that they fix the issue yourself?

Does the following command run without warnings or errors?

Have you taken a look at our contributing guidelines?

My node version matches the one suggested when running nvm use?

dgmouris commented 3 months ago

Here's how you get to the settings for adding the service account's permissions to the users calendar google-calendar-settings

dgmouris commented 3 months ago

For the service account creation.

  1. You're going to have to to create a service account documentation here
  2. It should look something like this. I know there's a key in there but this is a throwaway account. This is more for educational purposes. service-account-settings

Hopefully this helps and I can delete this message whenever if it's not useful.

dgmouris commented 3 months ago

@MandyMeindersma Let me know what you think about this whenever you have time.

dgmouris commented 3 months ago

Just for completionists sake, the endpoint json would return something like this (these are throw away events)

{
    "statusCode": 200,
    "message": "Success",
    "events": [
        {
            "kind": "calendar#event",
            "etag": "\"3429537132936000\"",
            "id": "6q60o3fo5sqnkeq68j6bhjlsfc",
            "status": "confirmed",
            "htmlLink": "https://www.google.com/calendar/event?eid=NnE2MG8zZm81c3Fua2VxNjhqNmJoamxzZmMgc3RldmUuc2hlZXRzZmFjZUBt",
            "created": "2024-05-03T01:11:57.000Z",
            "updated": "2024-05-03T20:36:06.468Z",
            "summary": "Test event friday.",
            "creator": {
                "email": "steve.sheetsface@gmail.com",
                "self": true
            },
            "organizer": {
                "email": "steve.sheetsface@gmail.com",
                "self": true
            },
            "start": {
                "dateTime": "2024-05-04T20:00:00-06:00",
                "timeZone": "America/Edmonton"
            },
            "end": {
                "dateTime": "2024-05-04T21:00:00-06:00",
                "timeZone": "America/Edmonton"
            },
            "iCalUID": "6q60o3fo5sqnkeq68j6bhjlsfc@google.com",
            "sequence": 1,
            "reminders": {
                "useDefault": true
            },
            "eventType": "default"
        },
        {
            "kind": "calendar#event",
            "etag": "\"3429542509008000\"",
            "id": "5civg5i4e3btljevb9jup2bpfj",
            "status": "confirmed",
            "htmlLink": "https://www.google.com/calendar/event?eid=NWNpdmc1aTRlM2J0bGpldmI5anVwMmJwZmogc3RldmUuc2hlZXRzZmFjZUBt",
            "created": "2024-05-03T21:19:05.000Z",
            "updated": "2024-05-03T21:20:54.504Z",
            "summary": "Second Event",
            "creator": {
                "email": "steve.sheetsface@gmail.com",
                "self": true
            },
            "organizer": {
                "email": "steve.sheetsface@gmail.com",
                "self": true
            },
            "start": {
                "dateTime": "2024-05-04T21:00:00-06:00",
                "timeZone": "America/Edmonton"
            },
            "end": {
                "dateTime": "2024-05-04T22:00:00-06:00",
                "timeZone": "America/Edmonton"
            },
            "iCalUID": "5civg5i4e3btljevb9jup2bpfj@google.com",
            "sequence": 0,
            "attendees": [
                {
                    "email": "steve.sheetsface@gmail.com",
                    "organizer": true,
                    "self": true,
                    "responseStatus": "accepted"
                },
                {
                    "email": "des-calendar-service-act-test@deveedmonton-testing-calendar.iam.gserviceaccount.com",
                    "responseStatus": "needsAction"
                }
            ],
            "reminders": {
                "useDefault": true
            },
            "eventType": "default"
        }
    ]
}
arashsheyda commented 3 months ago

@dgmouris this is great! if you would like we can excract this later to a Nuxt Module so others can use it? that can be a cool project!

dgmouris commented 3 months ago

So @arashsheyda I think later is key here, right now people will be able to read the endpoint /api/events/ with a GET request so that its flexible.

@arashsheyda do you mean as another project as a whole? If so the options here are pretty limitless!

dgmouris commented 3 months ago

PS. I think this is good to go once we test it and set up the service account with the devedmonton email :) Let me know your folks' thoughts.

arashsheyda commented 3 months ago

@dgmouris yes I meant after this PR gets merge we can create a new project e.g. devedmonton/nuxt-google-calendar-api and submit that to Nuxt Modules

dgmouris commented 3 months ago

@ajyong @MandyMeindersma I'm still getting familiar with the contributing to this site, I was wondering how I can get either some review/feedback/change requests on this PR :)

I would like to test this with the devedmonton google account as well if you folks feel comfortable with that:)

MandyMeindersma commented 3 months ago

My apologies @dgmouris @ajyong Normally I would try to review it in 2-3 days. Things have been crazy with work.

I will try to look at it in the next two days, again really sorry! And I'll look at trying to get you access to our google calendar

dgmouris commented 3 months ago

No problem @MandyMeindersma I was assuming you folks got a little busy with work, I just wanted to make sure this isn't forgotten :)

As a note, I think it would be best to merge this once we've tested it with the calendar :) Let me know how I can help or who I should talk if you folks need help :)

Thanks again!

MandyMeindersma commented 3 months ago

Still in the process of figuring out what I am supposed to be doing (the videos are very helpful @dgmouris thank you)

I did give you access to edit and add events on the public calendar for testing @dgmouris Feel free to make a mess of it. No one is currently using it. Also lemme know if I should add any of your students as well

MandyMeindersma commented 3 months ago

I am making progress!!!

I used to be getting the 400 "No Service Account Credentials Provided" but now I am getting: image

MandyMeindersma commented 3 months ago

image

MandyMeindersma commented 3 months ago

@allcontributors add @dgmouris for ideas, code and documentation

allcontributors[bot] commented 3 months ago

@MandyMeindersma

I've put up a pull request to add @dgmouris! :tada:

MandyMeindersma commented 3 months ago

Thank you so much @dgmouris for making the videos and making it so easy to follow! I am so sorry it took me so long to do this. That is not normal. Normally I get to reviews and asks within 2-3 days and I will be more timely as y'all are making more prs

Also the calendar is kinda bare right now because I have to ask ben how he did the meetup import to the calendar. And I'll be asking other organizers to add their events too! Yay!

dgmouris commented 2 months ago

Hey @MandyMeindersma thanks for taking the time to review this! I'm excited because I hope this is the beginning of the ground work where we can display all events in one place.