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='837647042410.apps.googleusercontent.com', client_secret='+SWwMCL9d8gWtzPRa1lXw5R8', scope='https://www.googleapis.com/auth/buzz', user_agent='buzz-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("buzz", "v1", http=http) activities = service.activities() activitylist = activities.list(scope='@consumption', userId='@me').execute() logging.info(activitylist) return render_to_response('buzz/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: 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("buzz", "v1", http=http) activities = service.activities() activitylist = activities.list(scope='@consumption', userId='@me').execute() logging.info(activitylist) return render_to_response('buzz/welcome.html', { 'activitylist': activitylist, })