I am trying to integrate google calendar into my web app without using OAuth. Since all calendars that I am working with are public, I am trying to use an API-key instead, to avoid having my users redirected.
I am currently playing around with the Calendar Event example and trying to get it to work with an API-key. Here is the code:
import httplib2
import os
from apiclient import discovery
import datetime
SCOPES = 'https://www.googleapis.com/auth/calendar'
api_key = '************'
APPLICATION_NAME = 'Google Calendar API Quickstart'
def main():
service = discovery.build('calendar', 'v3', developerKey=api_key)
event = {
'summary': 'Google I/O 2015',
'location': '800 Howard St., San Francisco, CA 94103',
'description': 'A chance to hear more about Google\'s developer products.',
'start': {
'dateTime': '2015-05-28T09:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
'end': {
'dateTime': '2015-05-28T17:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
'recurrence': [
'RRULE:FREQ=DAILY;COUNT=2'
],
'attendees': [
{'email': '******@*****.com'},
],
'reminders': {
'useDefault': False,
'overrides': [
{'method': 'email', 'minutes': 24 * 60},
{'method': 'popup', 'minutes': 10},
],
},
}
event = service.events().insert(calendarId='primary', body=event).execute()
#print 'Event created: %s' % (event.get('htmlLink'))
if __name__ == '__main__':
main()
When this runs it gives me the following error: googleapiclient.errors.HttpError: https://www.googleapis.com/calendar/v3/calendars/primary/events?alt=json&key=********* returned "Login Required">
Any help would be much appreciated