Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
May 20, 2024

Conversation

dgmouris
Copy link
Collaborator

@dgmouris dgmouris commented May 4, 2024

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 #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?

  • yes!
    image

Does the following command run without warnings or errors?

  • yes! npm run pr-checks

Have you taken a look at our contributing guidelines?

  • yes!

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

  • yes!
    I'm not using 18.17.0, I'm currently using 20.10.0 but I don't think that these changes should be an issue.

@dgmouris
Copy link
Collaborator Author

dgmouris commented May 4, 2024

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

@dgmouris
Copy link
Collaborator Author

dgmouris commented May 4, 2024

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
Copy link
Collaborator Author

dgmouris commented May 4, 2024

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

@dgmouris
Copy link
Collaborator Author

dgmouris commented May 4, 2024

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
Copy link
Collaborator

@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
Copy link
Collaborator Author

dgmouris commented May 6, 2024

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 dgmouris changed the title IN PROGRESS: API Endpoint for Events to be listed on the website /api/events API Endpoint for Events to be listed on the website /api/events May 6, 2024
@dgmouris
Copy link
Collaborator Author

dgmouris commented May 6, 2024

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
Copy link
Collaborator

@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
Copy link
Collaborator Author

@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
Copy link
Contributor

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
Copy link
Collaborator Author

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!

* @param {number} limitEvents - Limit the number of events to fetch (query param)
* @example
* // Example usage:
* // GET /api/events?startDate=2024-05-01&limitEvents=25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the comments so so much! Thank you!!

@MandyMeindersma
Copy link
Contributor

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
Copy link
Contributor

I am making progress!!!

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

@MandyMeindersma
Copy link
Contributor

image

@MandyMeindersma MandyMeindersma merged commit be4952a into devedmonton:main May 20, 2024
5 checks passed
@MandyMeindersma
Copy link
Contributor

@allcontributors add @dgmouris for ideas, code and documentation

Copy link
Contributor

@MandyMeindersma

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

@MandyMeindersma
Copy link
Contributor

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
Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants