storage = Storage(CredentialsModel, 'id', request.user, 'credential')
flow = OAuth2WebServerFlow(
client_secret=aaaaaaaaQ__-aaaaaaaaae',
user_agent='appname/1.0',
)
credential = storage.get()
if credential is None or credential.invalid == True:
authorize_url = flow.step1_get_authorize_url(STEP2_URI)
f = FlowModel(id=request.user, flow=flow)
f.save()
return HttpResponseRedirect(authorize_url)
else:
http = httplib2.Http()
http = credential.authorize(http)
service = build("calendar", "v3", http=http)
calendar_id = request.user.email