Пример #1
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import logging

from flask import current_app, Flask, redirect, request, session, url_for
import google.cloud.logging
from google.cloud.logging.handlers import CloudLoggingHandler, setup_logging
import httplib2
from oauth2client.contrib.flask_util import UserOAuth2

oauth2 = UserOAuth2()


def create_app(config, debug=False, testing=False, config_overrides=None):
    app = Flask(__name__)
    app.config.from_object(config)

    app.debug = debug
    app.testing = testing

    if config_overrides:
        app.config.update(config_overrides)

    # Configure logging
    if not app.testing:
        client = google.cloud.logging.Client(app.config['PROJECT_ID'])
Пример #2
0
from flask import Flask, jsonify, json, session, redirect, request, render_template
from oauth2client.contrib.flask_util import UserOAuth2

app = Flask(__name__)
app.debug = True

app.config['SECRET_KEY'] = 'RandomAss2.0Key'

# By default, if you don't define a scope, it uses the 'email' scope
# Google Plus API required
oauth2 = UserOAuth2(app, client_secrets_file='client_secrets.json')


# The Key is to have access_type='online', this means you don't ask for a refresh token
@app.route('/')
@oauth2.required(access_type='online')
def index():
    resp, content = oauth2.http().request(
        'https://www.googleapis.com/plus/v1/people/me/openIdConnect')
    return jsonify(**json.loads(content))


@app.route('/logout')
def logout():
    # Delete the user's profile and the credentials stored by oauth2.
    session.clear()
    session.modified = True
    oauth2.storage.delete()
    return redirect(request.referrer or '/')

Пример #3
0
from flask import Flask, render_template, request, redirect, session, url_for
import os
import datetime
import re
from flaskext.mysql import MySQL
from flask_restful import Resource, Api, reqparse
from oauth2client.contrib.flask_util import UserOAuth2
from oauth2client.client import OAuth2Credentials
import simplejson as json
from jupyter_generator import main

app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret_key'
app.config['GOOGLE_OAUTH2_CLIENT_ID'] = 'client_id'
app.config['GOOGLE_OAUTH2_CLIENT_SECRET'] = 'client_secret'
oauth2 = UserOAuth2(app)

mysql = MySQL()
app.config['MYSQL_DATABASE_USER'] = '******'
app.config['MYSQL_DATABASE_PASSWORD'] = '******'
app.config['MYSQL_DATABASE_DB'] = 'heroku_db'
app.config['MYSQL_DATABASE_HOST'] = 'host'
mysql.init_app(app)
app.secret_key = 'secret_keys'


@app.route('/', methods=['GET', 'POST'])
def index():
    if not session.get('user_id'):
        return render_template('landing.html')
    else:
Пример #4
0
import datetime
from decimal import Decimal

import apiclient
from oauth2client.contrib.flask_util import UserOAuth2

from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.image import MIMEImage
from email.mime.application import MIMEApplication
import base64

from google.appengine.api import urlfetch

OAUTH2 = UserOAuth2(app)
CALENDAR = apiclient.discovery.build('calendar', 'v3')
SCOPES = [
    "https://www.googleapis.com/auth/calendar",
    "https://www.googleapis.com/auth/spreadsheets",
    'https://www.googleapis.com/auth/gmail.send'
]


@app.route('/')
def homepage():
    return render_template('homepage.html')


@app.route('/view_bookings')
def list_bookings():