public
anonymous / content.py
Created

  • Download Gist
content.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
#!/usr/bin/env python
#
# Copyright 2012 Cometoide.
# @author: samiq
#
import os
import webapp2
import base_handlers
from google_spreadsheet.api import SpreadsheetAPI
import gdata.apps.groups.client
 
import endpoints
import httplib2
import urllib
from apiclient.discovery import build
from oauth2client.file import Storage
from oauth2client.client import OAuth2WebServerFlow
from oauth2client.tools import run
import json
import atom.data
import gdata.sites.client
import gdata.sites.data
 
FLOW = OAuth2WebServerFlow(client_id=endpoints.CLIENT_ID,
client_secret=endpoints.CLIENT_SECRET,
scope=endpoints.SCOPE,
redirect_uri=endpoints.REDIRECT_URI,
user_agent='')
 
http = httplib2.Http()
 
class Home(base_handlers.BasicHandler):
def get(self):
file_name = 'public/index.html'
template_values = {}
self.render_response(file_name, **template_values)
class Login(base_handlers.BasicHandler):
def get(self):
file_name = 'public/login.html'
auth_uri = FLOW.step1_get_authorize_url()
template_values = {'auth_uri' : auth_uri}
self.render_response(file_name, **template_values)
class CallbackHandler(base_handlers.BasicHandler):
def get(self):
a_c = self.request.get('code')
credentials = FLOW.step2_exchange(a_c)
global http
http = credentials.authorize(http)
self.redirect('/form')

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.