This is a follow on from my thread about a 401 error when using the Google Calendar API and OAuth2, which can be found here
This contains details of the account setu
I was also getting the same error even after sharing the calendar as in the Justin's answer. After comparing with another working sample figured out that I have set
var SCOPES = ["https://www.googleapis.com/auth/calendar.readonly"];
instead of
var SCOPES = ["https://www.googleapis.com/auth/calendar"];
Hope this helps anyone who has done a similar mistake and getting this error.