Get events from google calendar


I would like to get a list of events between two dates (start /end) or all events for the next (3 / 7) days.
I'm currently using # node-red-node-google 0.1.4

My problem is, that these nodes only provide the option to get the next event and nothing more.

Anybody who knows how to get achieve my goals?


So long,

1 Like

The node currently doesn't do that.

You could write your own, or even better, add the functionality to the current node after speaking to it's author and benefit the entire community.

Indeed... we would welcome improvements to that node.

Sorry, I'm not a Javascript programmer. That is why I asked here to e.g. get a hint to use another node or something like that.
I can try to write a python script :slight_smile: but that won't help the node.

Too sad, that there seems no other already working node for that task.

If you think you can write it in python then with a minimal bit of learning you should be able to do it in javascript. Especially when you are starting with a working node and just need to add features to it.

node-red-node-google is not working at all. However, there is node-red-contrib-google node which is wrapping Google API and is working like a charm. It's also much more flexible.

Put inject node and send

    "calendarId": "",
    "timeMin": "2018-11-19T09:11:13.562Z",
    "timeMax": "2018-11-21T09:11:13.562Z"

to google node. On google node set API to calendar:v3 and Operation to events.list (of course you could leave that empty and provide everything by input node). timeMin and timeMax is what you want to create time window. Just checked it, works perfectly.

Of course, you need to configure google node but that is extremely simply (not like node-red-node-google):

1 Like

Whist node-red-node-google was not working for you, there are others, that for what it was designed to do, it works perfectly well. It is incorrect to say it is not working at all.

But I'm happy you have managed to achieve what you want and thanks for sharing it.

I've tested it on 3 completely different instances of NR on different machines and even architecture with different Google accounts. Every time the result was the same: success but no credentials were stored preventing that node from working - hence my comment.

Anyway, we can agree that the second node wrapping whole API fits the requirements and do the job.

Thanks, I installed the node. Copied the complete credentials.json file into the config node.
After that I tried your example. The configuration seems ok, but as response in the debug tab, I only get "Error: Not found".

Any idea what I did wrong?

Pick CalendarList.list as Operation and check if you have access to that particular calendar. If you see something in payload.items then copy id of that calendar and us it as calendarId for events.list call.

I got this:

22.11.2018, 13:28:00node: 5255c83.a57ca38
msg : Object
_msgid: "3f48035.f465efc"
topic: ""
payload: object
kind: "calendar#calendarList"
etag: ""p3000""
nextSyncToken: "CAASG1lZ2FjYWwtMTU0MTc5NjUwMDQyMi5pYW0uZ3ZZDSDSDSD)(ZpY2VhY2NvdW50LmNvbQ=="
items: array[0]

Ok, so items is empty, so you have no access to any calendar from this account.

  1. If you go to console and click IAM & admin on the left, do you see service account item in the table? (key icon, hover over to see type in string)
  2. now if you go to your calendar settings, can you see the exact mail in share section?

Yes, it seems to work. Thank you. I didn't konw that I have to "open" the calendar for that generated email address. I thought all the keys and ids would be enough :slight_smile:

Well, you don't have to "open" the calendar for that generated email. You have to open any calendar you would like to view in NR and share it with that generated email :slight_smile: So that generated email (service account) is like a user for your API (NodeRed).

Yes, that's ok. You need a "user" to access the calender. But I thought giving the crendentials.json file to the configuration node would be enough.

Yeah, that's the small issue with this node. It stores this JSON key in a way that it's being shared with the flow, so be careful with sharing your flow or pushing it to git.

I am lost after generate JSON key.
in IAM & admin I can see an related mail account fo rthe key.
But how to use ?
I tryed to put in the key in the JSON field of the connection node. But what about the Scopes field ?

best regards

@uwaechte using the email account you found in the 'IAM & Admin' section, go to your calendar's settings in Google Calendar and share the calendar with that email address.

Within the 'Scopes' field put the following:

Having all of those might be overkill for your use but that is all the Scopes for the Calendar API

many thank's that was the missing information

EDIT: Figured it out! I used the following template with a timestamp inject and moment conversion. No idea if this is the best way to do what I need but it works...

    "calendarId": "___",
    "maxResults": "1",
    "orderBy": "startTime",
    "timeMin": "{{payload}}",
    "singleEvents": "true"

Thanks for the help - this topic helped me set this up.

Just struggling with one thing - how do I return just the next occurring event? I have a recurring event and I need just the next instance returned, but it's giving me all events ever added to calendar. I've read through the Google Calendar API documents and have tried a bunch of stuff. I can get it to give me only one result but can't figure out the rest. For some reason it only lets you sort by date.

I tried using simpletime and passing myrawdate into a template of this:

    "calendarId": "_____",
    "maxResults": "1",
    "orderBy": "startTime",
    "timeMin": "{{myrawdate}}"

I get this as the payload:

payload: object
calendarId: "_____"
maxResults: "1"
orderBy: "startTime"
timeMin: "Sun Feb 17 2019 22:51:53 GMT-0500 (EST)"

But it obviously doesn't work. I know no programming, so I'm kind of just guesting here...I think it's changing the format of myrawdate but not sure why. Using moment, I can get the right time stamp but getting a different error.

"Error: The requested ordering is not available for the particular query."