Exemplo n.º 1
0
from simplekv.memory import DictStore
from flaskext.kvsession import KVSessionExtension

from contextlib import closing

app = Flask(__name__)
app.config.from_object('config')
app.secret_key = ''.join(
    random.choice(string.ascii_uppercase + string.digits) for x in xrange(32))
APPLICATION_NAME = 'Productive'

# See the simplekv documentation for details
store = DictStore()

# This will replace the app's session handling
KVSessionExtension(store, app)

# Update client_secrets.json with your Google API project information.
# Do not change this assignment.
CLIENT_ID = json.loads(open('client_secrets.json',
                            'r').read())['web']['client_id']
SERVICE = build('plus', 'v1')


def is_authenticated():
    # Only disconnect a connected user.
    credentials = session.get('credentials')
    google_id = session.get('google_id')
    if credentials is None or google_id is None:
        return False
        #    abort(401)
Exemplo n.º 2
0
from oauth2client.appengine import StorageByKeyName
from oauth2client.appengine import CredentialsModel

from simplekv.memory import DictStore
from flaskext.kvsession import KVSessionExtension

from google.appengine.ext import ndb
from models import CronCards, UserProperties

glassdailycard = Flask('glass-daily-card')
glassdailycard.secret_key = ''.join(
    random.choice(string.ascii_uppercase + string.digits) for x in xrange(32))

# Handles our sessions
store = DictStore()
KVSessionExtension(store, glassdailycard)


def _oauth_flow():
    """Prepare an OAuth flow."""
    required_scopes = ('https://www.googleapis.com/auth/glass.location',
                       'https://www.googleapis.com/auth/glass.timeline',
                       'https://www.googleapis.com/auth/plus.login')
    oauthflow = flow_from_clientsecrets('client_secrets.json',
                                        scope=required_scopes,
                                        redirect_uri='postmessage')
    oauthflow.params['access_type'] = 'offline'
    return oauthflow


def _authorized_http(credentials):