76 lines
2.1 KiB
Python
76 lines
2.1 KiB
Python
from oauth2client.client import OAuth2WebServerFlow
|
|
from apiclient.discovery import build
|
|
from oauth2client.file import Storage
|
|
import httplib2
|
|
|
|
|
|
flow = OAuth2WebServerFlow(client_id='34462582242-4kpdvvbi27ajt4u22uitqurpve9o8ipj.apps.googleusercontent.com',
|
|
client_secret='y4t9XBrJdCODPTO5UvtONWWn',
|
|
scope='https://www.googleapis.com/auth/calendar',
|
|
redirect_uri='http://localhost')
|
|
|
|
|
|
#auth_uri = flow.step1_get_authorize_url()
|
|
#print "AuthURI:"
|
|
#print auth_uri
|
|
#exit(0)
|
|
|
|
#code="4/z524dROAcIc24igDftg99LqjyJPG.4jR5ZcA_RPYaOl05ti8ZT3a5aIW3hAI"
|
|
#credentials = flow.step2_exchange( code )
|
|
|
|
storage = Storage('calendarCredentials.dat')
|
|
credentials = storage.get()
|
|
if credentials is None or credentials.invalid == True:
|
|
print "Invalid credentials"
|
|
exit( 0)
|
|
|
|
|
|
http = httplib2.Http()
|
|
http = credentials.authorize( http )
|
|
service = build( serviceName='calendar', version='v3', http=http, developerKey='blechreiz-homepage' )
|
|
calendarId = 'blechreizensemble@gmail.com'
|
|
|
|
|
|
def getEvents(pageToken=None):
|
|
events = service.events().list(
|
|
calendarId='primary',
|
|
singleEvents=True,
|
|
maxResults=1000,
|
|
orderBy='startTime',
|
|
timeMin='2012-11-01T00:00:00-08:00',
|
|
timeMax='2018-11-30T00:00:00-08:00',
|
|
pageToken=pageToken,
|
|
).execute()
|
|
return events
|
|
|
|
|
|
def createEvent():
|
|
print ( "Creating Event ")
|
|
event = {
|
|
'summary': 'Blechreiz Probe',
|
|
'description': 'Eine Beschreibung.. bitte alle instrumente mitbringen',
|
|
'location': 'Rohr',
|
|
'start': {
|
|
'dateTime': '2014-03-23T19:00:00',
|
|
'timeZone': 'Europe/Berlin'
|
|
},
|
|
'end': {
|
|
'dateTime': '2014-03-23T23:05:00',
|
|
'timeZone': 'Europe/Berlin'
|
|
},
|
|
'attendees': [
|
|
{
|
|
'id': 'martinbauer86@gmail.com',
|
|
'email': 'martinbauer86@gmail.com',
|
|
'displayName': "MartinB",
|
|
},
|
|
],
|
|
}
|
|
created_event = service.events().insert(calendarId='primary', body=event).execute()
|
|
|
|
|
|
print created_event['id']
|
|
|
|
|
|
#createEvent()
|
|
print getEvents() |