def index(request): storage = Storage(CredentialsModel, 'id', request.user, 'credential') credential = storage.get() if credential is None or credential.invalid == True: flow = OAuth2WebServerFlow( client_id='[[Insert Client ID here.]]', client_secret='[[Insert Client Secret here.]]', scope='https://www.googleapis.com/auth/plus.me', user_agent='plus-django-sample/1.0', ) 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("plus", "v1", http=http) activities = service.activities() activitylist = activities.list(collection='public', userId='me').execute() logging.info(activitylist) return render_to_response('plus/welcome.html', { 'activitylist': activitylist, })
def index(request): storage = Storage(CredentialsModel, 'id', request.user, 'credential') credential = storage.get() if credential is None or credential.invalid == True: flow = OAuth2WebServerFlow(client_id=settings.CLIENT_ID, client_secret=settings.CLIENT_SECRET, scope=settings.SCOPE, user_agent='plus-django-sample/1.0') authorize_url = flow.step1_get_authorize_url(settings.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("plus", "v1", http=http) activts = service.activities() activitylist = activts.list(userId='me', collection='public').execute() logging.info(activitylist) return TemplateResponse(request, 'plus/welcome.html', { 'activitylist': activitylist, })