We have done it in WINDEV22 using OAUTH2 for authentication, the Graph API for MS and Calendar API for google
[
docs.microsoft.com]
[
developers.google.com]
All is done using httpRequest and httpResponse and httpsend function.
Sample code (very simple one) to create one event:
//GOOGLE
res_var is Variant
wbody is string=[
{
"summary": "Ferias varios dias",
"description": "Ferias varios",
"start": {
"date": "2019-05-31",
"timeZone": "Europe/London"
},
"end": {
"date": "2019-06-05",
"timeZone": "Europe/London"
}
}
]
HTTPTimeOut(600000)
HTTP.IgnoreError = httpIgnoreInvalidCertificate+httpIgnoreInvalidCertificateName+httpIgnoreExpiredCertificate+httpIgnoreRedirectToHTTP+httpIgnoreRedirectToHTTPS
cMyRequest is httpRequest
cMyRequest..URL = "[
www.googleapis.com];
cMyRequest..Header["Authorization"]="Bearer "+p_access_token
cMyRequest..Content=wbody
cMyRequest..ContentType="application/json"
cMyRequest..IgnoreError = httpIgnoreInvalidCertificate+httpIgnoreInvalidCertificateName+httpIgnoreExpiredCertificate+httpIgnoreRedirectToHTTP+httpIgnoreRedirectToHTTPS
cMyRequest..Method=httpPost
cMyResponse is httpResponse = HTTPSend(cMyRequest)
IF ErrorOccurred THEN
Error("Erro na criação de eventyo",ErrorInfo(errFullDetails))
END
WHEN EXCEPTION IN
res_var=JSONToVariant(cMyResponse..Content)
DO
Info("não é um JSON valido",cMyResponse..Content)
RETURN
END
IF res_var.error..Exist THEN
Info("erro token criar evento",cMyResponse..Content)
RETURN
END
MOSTRA_RESULTADO=VariantToJSON(res_var,psdFormatting)
MyWindow..Plane=3
WHILE MyWindow..Plane<>2
Multitask(-1)
CONTINUE
END
//MS
//
res_var is Variant
wbody is string=[
{
"subject": "Ferias varios dias",
"isReminderOn": "False",
"isAllDay": "True",
"hasAttachments": "false",
"responseRequested": "False",
"categories": ["FERIAS"],
"showAs": "oof",
"body": {
"contentType": "HTML",
"content": "Ferias xxx"
},
"start": {
"dateTime": "2019-05-31T00:00:00",
"timeZone": "Europe/London"
},
"end": {
"dateTime": "2019-06-05T00:00:00",
"timeZone": "Europe/London"
}
}
]
HTTPTimeOut(600000)
HTTP.IgnoreError = httpIgnoreInvalidCertificate+httpIgnoreInvalidCertificateName+httpIgnoreExpiredCertificate+httpIgnoreRedirectToHTTP+httpIgnoreRedirectToHTTPS
cMyRequest is httpRequest
cMyRequest..URL = "[
graph.microsoft.com];
cMyRequest..Header["Authorization"]="Bearer "+p_access_token
cMyRequest..Content=wbody
cMyRequest..ContentType="application/json"
cMyRequest..IgnoreError = httpIgnoreInvalidCertificate+httpIgnoreInvalidCertificateName+httpIgnoreExpiredCertificate+httpIgnoreRedirectToHTTP+httpIgnoreRedirectToHTTPS
cMyRequest..Method=httpPost
cMyResponse is httpResponse = HTTPSend(cMyRequest)
IF ErrorOccurred THEN
Error("Erro na criação de eventyo",ErrorInfo(errFullDetails))
END
WHEN EXCEPTION IN
res_var=JSONToVariant(cMyResponse..Content)
DO
Info("não é um JSON valido",cMyResponse..Content)
RETURN
END
IF res_var.error..Exist THEN
Info("erro token criar evento",cMyResponse..Content)
RETURN
END
IF cMyResponse..StatusCode="201" THEN
MOSTRA_RESULTADO=VariantToJSON(res_var,psdFormatting)
MyWindow..Plane=3
WHILE MyWindow..Plane<>2
Multitask(-1)
CONTINUE
END
ELSE
Info("erro criar evento",cMyResponse..Content)
END
Regards
Paulo Oliveira