veebch / hometime

A physical progress bar based on Google Calendar events
GNU General Public License v3.0
45 stars 6 forks source link

How to add API Key on google calendar #4

Closed danionescu0 closed 1 year ago

danionescu0 commented 1 year ago

Hi there. Fist of all i like your project it looks great! I've already replicated part of it:) But for the part of the integration with Google Calendar API i'm having some issues. Now that the code has migrated from OAUTH and a local server to directly accessing the Google Calendar API i can't get it working because in My Google Calendar API / Credentials section i only have two options: OAuth 2.0 Client IDs and Service Accounts.

Is this a coutry based limitation, or maybe i'm not looking in the right section of the configuration?

thanks!

veebch commented 1 year ago

Thanks, glad you like it. As for the Calendar bit....So much for simplicity :)

Even though I made my calendar public (by publishing to web) I needed an API key or Google would bounce me.

One thing I had to do was set my API key to unrestricted access. Maybe that helps?

danionescu0 commented 1 year ago

Thank you for the very quick response, i've also made a test calendar public. But i don't know how to create that API Key yet. I thought it was simple :)

veebch commented 1 year ago

This page?

https://console.cloud.google.com/apis/credentials

danionescu0 commented 1 year ago

I've created a new calendar project and now it lets me add te API key I'm using this api to try read events from the calendar

API_KEY="YOUR_API_KEY" TIME_MIN="2023-05-21T00:00:00Z" TIME_MAX="2023-05-28T23:59:59Z"

curl "https://www.googleapis.com/calendar/v3/calendars/primary/events?key=${API_KEY}&timeMin=${TIME_MIN}&timeMax=${TIME_MAX}"

But it sais not found, still it seems that i'm on the right track thanks

veebch commented 1 year ago

The API key needs to replace the bit in the quotes on the code. That should do it :)

danionescu0 commented 1 year ago

Shell replaces my variables defined before, but still the project seems not found, maybe there is more on the configuration side, i need to dig into that

danionescu0 commented 1 year ago

Ok got it working, i should have use the calendar in (in form of an email address), my calendar was not primary. Thanks for your help, this resource really helped a lot https://console.cloud.google.com/apis/credentials

veebch commented 1 year ago

Excellent. Closing, but I'll add the link to the readme....