Created
March 8, 2013 12:30
-
-
Save anonymous/5116161 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment