I want to extend the functionality of a service available via ServiceConnect
, particularly Google Calendar to insert a new event.
That action requieres authentication via OAuth2, and that can be done by
googlecalendar = ServiceConnect["GoogleCalendar"]
The Google API documentation is available here
https://developers.google.com/calendar/v3/reference/events/insert
It indicates that to create an event one needs to POST
a body like this
{
"end": {
"date": "2018-06-19"
},
"start": {
"date": "2018-06-18"
}
}
I don't know how to use the already authenticated service connection to POST
my request. I'm guessing that OAuthClient`rawoauthdata
should help.
I know this code does not work, but I would like to do something like
Module[
{
id=googlecalendar["ID"],
calendarId= "calendarIdString",
url,
body="{
\"end\": {
\"date\": \"2018-06-19\"
},
\"start\": {
\"date\": \"2018-06-18\"
}
}"
},
url=StringTemplate[
"https://www.googleapis.com/calendar/v3/calendars/`1`/events/insert"
][calendarId];
OAuthClient`rawoauthdata[
id,
url,
{
"method" -> "POST",
"body" -> body
}
]
]
EDIT
As per suggestion by @b3m2a1, I'm open to the possibility of editing the paclet itself, even if that seems to me implies a much more serious task of making the new function consistent with the rest.
In any of the two cases I'm missing the intermediate information that links the high level and still cryptic OAuthClient
with the low level construction of a URLFetch
call, defining proper headers, body and so on. I don't understand how they relate, and all the examples I can see in other programming languages are high level.
So, I'm restating my question, inside or outside the paclet,
How to implement a function that uses POST and OAuth to achieve inserting an event in Google Calendar?
"GCal"
connection or something which you can customize at will. $\endgroup$OAuthClient
functions, for which I can't find much understandable information. $\endgroup$