Home > Back-end >  Can not send OAuth 2.0 token to google via Outlook VBA
Can not send OAuth 2.0 token to google via Outlook VBA

Time:12-07

I am trying to update my Google Calendar from a desktop version of Outlook. When I add an event to my outlook calendar, the following VBA code is executed:

Set httpCall = CreateObject("MSXML2.ServerXMLHTTP")
Dim sURL As String
sURL = "https://www.googleapis.com/calendar/v3/calendars/<my google gmail account>/events?sendNotifications=false&fields=etag,htmlLink,id&pp=1&access_token=<my OAuth 2.0 client id>"
httpCall.Open "POST", sURL, False
httpCall.setRequestHeader "Content-Type", "application/json;charset=UTF-8"
httpCall.Send Json
Dim sReturn As String
sReturn = httpCall.responseText

The value of sReturn at the end of executing the code is this:

enter image description here

I have an OAuth 2.0 client id and client secret but obviously, I dont have something set up correctly.

Any assistance is greatly appreciated.

Thank you.

CodePudding user response:

The error message says you need to pass an access token or other valid authentication credentials to get the job done. The code is not authorized.

You may find the enter image description here

Insert Event

While you have stated that you are trying to update your google calendar, from your code and the erro message it actually looks like you are trying to create a new event using enter image description here

  • Related