Exemple #1
0
def init_oauth(app):
    global o_twitter, o_facebook, oauth_authorized

    oauth = OAuth()
    o_twitter = oauth.remote_app('twitter',
        base_url='https://api.twitter.com/1/',
        request_token_url='https://api.twitter.com/oauth/request_token',
        access_token_url='https://api.twitter.com/oauth/access_token',
        authorize_url='https://api.twitter.com/oauth/authenticate',
        consumer_key=app.config["OAUTH_TWITTER_CONSUMER_KEY"],
        consumer_secret=app.config["OAUTH_TWITTER_CONSUMER_SECRET"],
        access_token_method='POST'
    )
    user.add_url_rule('/oauth/twitter', "twitter_authorized", o_twitter.authorized_handler(twitter_authorized))
    o_twitter.tokengetter(oauth_token)

    o_facebook = oauth.remote_app('facebook',
        base_url='https://graph.facebook.com/',
        request_token_url=None,
        access_token_url='/oauth/access_token',
        authorize_url=app.config["OAUTH_FACEBOOK_SITE_URL"],
        consumer_key=app.config["OAUTH_FACEBOOK_CONSUMER_KEY"],
        consumer_secret=app.config["OAUTH_FACEBOOK_CONSUMER_SECRET"],
        request_token_params={'scope': 'email'}
    )
    user.add_url_rule('/oauth/facebook', "facebook_authorized", o_facebook.authorized_handler(facebook_authorized))
    o_facebook.tokengetter(oauth_token)
    def get_github_oauth_client(self, site=None,
            scope='', token='github_oauth_token'):
        """Returns a instance of LinkedIn OAuth

        :param site: Browserecord of the website, If not specified, it will be
                     guessed from the request context
        """
        if site is None:
            site = request.nereid_website

        if not all([site.github_id, site.github_secret]):
            current_app.logger.error("Github api settings are missing")
            flash(_("Github login is not available at the moment"))
            return None

        oauth = OAuth()
        github = oauth.remote_app('github',
            base_url='https://github.com',
            request_token_url=None,
            access_token_url='/login/oauth/access_token',
            authorize_url='/login/oauth/authorize',
            consumer_key=site.github_id,
            consumer_secret=site.github_secret,
            request_token_params={'scope': scope},
            access_token_method="POST",
        )
        github.tokengetter_func = lambda *a: session.get(token)
        return github
    def get_github_oauth_client(self,
                                site=None,
                                scope='',
                                token='github_oauth_token'):
        """Returns a instance of LinkedIn OAuth

        :param site: Browserecord of the website, If not specified, it will be
                     guessed from the request context
        """
        if site is None:
            site = request.nereid_website

        if not all([site.github_id, site.github_secret]):
            current_app.logger.error("Github api settings are missing")
            flash(_("Github login is not available at the moment"))
            return None

        oauth = OAuth()
        github = oauth.remote_app(
            'github',
            base_url='https://github.com',
            request_token_url=None,
            access_token_url='/login/oauth/access_token',
            authorize_url='/login/oauth/authorize',
            consumer_key=site.github_id,
            consumer_secret=site.github_secret,
            request_token_params={'scope': scope},
            access_token_method="POST",
        )
        github.tokengetter_func = lambda *a: session.get(token)
        return github
Exemple #4
0
from celery import Celery

from nomenklatura import default_settings

logging.basicConfig(level=logging.DEBUG)

app = Flask(__name__)
app.config.from_object(default_settings)
app.config.from_envvar('NOMENKLATURA_SETTINGS', silent=True)

db = SQLAlchemy(app)
s3 = S3Connection(app.config['S3_ACCESS_KEY'], app.config['S3_SECRET_KEY'])
celery = Celery('nomenklatura', broker=app.config['CELERY_BROKER'])

oauth = OAuth()
github = oauth.remote_app(
    'github',
    base_url='https://github.com/login/oauth/',
    authorize_url='https://github.com/login/oauth/authorize',
    request_token_url=None,
    access_token_url='https://github.com/login/oauth/access_token',
    consumer_key=app.config.get('GITHUB_CLIENT_ID'),
    consumer_secret=app.config.get('GITHUB_CLIENT_SECRET'))

github._client.ca_certs = certifi.where()
memcache = MemcacheClient(
    servers=[app.config.get('MEMCACHE_HOST', '127.0.0.1:11211')],
    username=os.environ.get('MEMCACHIER_USERNAME'),
    password=os.environ.get('MEMCACHIER_PASSWORD'),
    binary=True)
Exemple #5
0
from flaskext.oauth import OAuth
from trackcircle.config import FACEBOOK_APP_ID, FACEBOOK_APP_SECRET

oauth = OAuth()
facebook = oauth.remote_app(
    'facebook',
    base_url='https://graph.facebook.com/',
    request_token_url=None,
    access_token_url='/oauth/access_token',
    authorize_url='https://www.facebook.com/dialog/oauth',
    consumer_key=FACEBOOK_APP_ID,
    consumer_secret=FACEBOOK_APP_SECRET,
    request_token_params={'scope': 'email'})
Exemple #6
0
from flask import Module,Blueprint, render_template, request, redirect, url_for, flash, session, abort
from flaskext.oauth import OAuth
from app.model.entry import EntryModel
from app.model.user import UserModel
from app.controller.forms import EntryForm, LoginForm, CreateUserForm
from app.controller.component.pagination import Pagination

PER_PAGE = 5
#app = Blueprint('board', __name__)
app = Module(__name__)

oauth = OAuth()
twitter = oauth.remote_app('twitter',
    base_url='https://api.twitter.com/1/',
    request_token_url='https://api.twitter.com/oauth/request_token',
    access_token_url='https://api.twitter.com/oauth/access_token',
    authorize_url='https://api.twitter.com/oauth/authenticate',
    consumer_key='E7xMzCcx6yoONKkQMXXNQ',
    consumer_secret='sB8iO1pvFKS6eRegFBkXkP34PCoxiAhXLTB6myzf4M'
)

@twitter.tokengetter
def get_twitter_token():
    return session.get('twitter_token')

@app.route('/', defaults={'page': 1})
@app.route('/page/<int:page>')
def index(page):
    count = EntryModel.get_all_count()
    start = (page - 1) * PER_PAGE  
    end = start + PER_PAGE
    entries = EntryModel.get_entries(start, end)
Exemple #7
0
from flaskext.oauth import OAuth
from flask import session

import params

oauth = OAuth()
twitter = oauth.remote_app('twitter',
    base_url='https://api.twitter.com/1/',
    request_token_url='https://api.twitter.com/oauth/request_token',
    access_token_url='https://api.twitter.com/oauth/access_token',
    authorize_url='https://api.twitter.com/oauth/authorize',
    consumer_key=params.twitter['consumer_key'],
    consumer_secret=params.twitter['consumer_secret']
)

google = oauth.remote_app('google',
    base_url='https://www.google.com/accounts/',
    authorize_url='https://accounts.google.com/o/oauth2/auth',
    request_token_url=None,
    request_token_params={'scope': 'https://www.googleapis.com/auth/userinfo.email',
                        'response_type': 'code'},
    access_token_url='https://accounts.google.com/o/oauth2/token',
    access_token_method='POST',
    access_token_params={'grant_type': 'authorization_code'},
    consumer_key=params.google['consumer_key'],
    consumer_secret=params.google['consumer_secret']
)

@twitter.tokengetter
def get_twitter_token():
    return session.get('twitter_token')
Exemple #8
0
app.config['DEBUG'] = True
SECRET_KEY = 'development key'
#app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://*****:*****@ec2-23-23-234-187.compute-1.amazonaws.com/resource44881'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///testdb.sqlite'
db = flask.ext.sqlalchemy.SQLAlchemy(app)
TWITTER_APP_ID = '8YsjtlJjL8kRaGDv1SZjmQ'
TWITTER_APP_SECRET_ID = 'QVAWDUstIpIHWhZegr5CqQm1XJHWtBIzOacQdXzP7o'

app.secret_key = SECRET_KEY
oauth = OAuth()

twitter = oauth.remote_app('twitter',
	base_url = 'http://api.twitter.com/1/',
	request_token_url = 'https://api.twitter.com/oauth/request_token',
	access_token_url = 'https://api.twitter.com/oauth/access_token',
	authorize_url = 'https://api.twitter.com/oauth/authorize',
	#authorize_url='http://api.twitter.com/oauth/authenticate',
	consumer_key = TWITTER_APP_ID,
	consumer_secret = TWITTER_APP_SECRET_ID
	)


# User Table Exception and Validation handling
class userValidation(Exception):
	pass

# Star Table Exception and Validation handling
class starValidation(Exception):
	pass

Exemple #9
0
from flask import Blueprint, g, url_for, redirect, session, request, flash, render_template, jsonify
from flaskext.oauth import OAuth
from app import main
import random

etsy = Blueprint('etsy', __name__)

oauth = OAuth()
api = oauth.remote_app('etsy',
    base_url = main.config['ETSY_BASE_URL'],
    request_token_url= main.config['ETSY_REQUEST_TOKEN_URL'],
    access_token_url= main.config['ETSY_ACCESS_TOKEN_URL'],
    authorize_url= main.config['ETSY_AUTHORIZE_URL'],
    consumer_key= main.config['ETSY_CONSUMER_KEY'],
    consumer_secret= main.config['ETSY_CONSUMER_SECRET'],
    request_token_params=dict(scope= main.config['ETSY_SCOPE'], limit=main.config['ETSY_API_LIMIT'])
)

### routes ###
@etsy.route('/')
def index():
    access_token = get_token();
    if access_token is None:
        return redirect(url_for('etsy.register'))

    return redirect(url_for('create_postcard'))

### auth routes ###
@etsy.route('/register')
def register():
    return api.authorize(callback=url_for('etsy.verify', next=request.args.get('next') or request.referrer or None))
Exemple #10
0
from flask import Module, Blueprint, render_template, request, redirect, url_for, flash, session, abort
from flaskext.oauth import OAuth
from app.model.entry import EntryModel
from app.model.user import UserModel
from app.controller.forms import EntryForm, LoginForm, CreateUserForm
from app.controller.component.pagination import Pagination

PER_PAGE = 5
#app = Blueprint('board', __name__)
app = Module(__name__)

oauth = OAuth()
twitter = oauth.remote_app(
    'twitter',
    base_url='https://api.twitter.com/1/',
    request_token_url='https://api.twitter.com/oauth/request_token',
    access_token_url='https://api.twitter.com/oauth/access_token',
    authorize_url='https://api.twitter.com/oauth/authenticate',
    consumer_key='E7xMzCcx6yoONKkQMXXNQ',
    consumer_secret='sB8iO1pvFKS6eRegFBkXkP34PCoxiAhXLTB6myzf4M')


@twitter.tokengetter
def get_twitter_token():
    return session.get('twitter_token')


@app.route('/', defaults={'page': 1})
@app.route('/page/<int:page>')
def index(page):
    count = EntryModel.get_all_count()
    start = (page - 1) * PER_PAGE
from flask.globals import g
from flask.helpers import flash

# blueprint for authenication pages
from orm import User

authweb = Blueprint('authweb', __name__)

# TWITTER AUTH STUFF:

# OAuth config:
oauth = OAuth()
twitter = oauth.remote_app('twitter',
    base_url='http://api.twitter.com/1/',
    request_token_url='http://api.twitter.com/oauth/request_token',
    access_token_url='http://api.twitter.com/oauth/access_token',
    authorize_url='http://api.twitter.com/oauth/authenticate',
    consumer_key='u9ePtkkR3z9zYicizhzdQ',
    consumer_secret='is1UoQghHUz3k2CjpzSnkgqWPxojuvvzWBOiSWLUWs'
)

@twitter.tokengetter
def get_twitter_token():
    return session.get('twitter_token')

# pages for twitter auth:

@authweb.route('/oauth-authorized')
@twitter.authorized_handler
def oauth_authorized(resp):
    next_url = request.args.get('next') or url_for('index')
    if resp is None:
Exemple #12
0
from werkzeug.contrib.atom import AtomFeed

from blog import db
#db = Connection().blog

oauth = OAuth()

twitter = oauth.remote_app(
    'twitter',
    # unless absolute urls are used to make requests, this will be added
    # before all URLs.  This is also true for request_token_url and others.
    base_url='http://api.twitter.com/1/',
    # where flask should look for new request tokens
    request_token_url='https://api.twitter.com/oauth/request_token',
    # where flask should exchange the token with the remote application
    access_token_url='https://api.twitter.com/oauth/access_token',
    # twitter knows two authorizatiom URLs.  /authorize and /authenticate.
    # they mostly work the same, but for sign on /authenticate is
    # expected because this will give the user a slightly different
    # user interface on the twitter side.
    authorize_url='http://api.twitter.com/oauth/authenticate',
    # the consumer keys from the twitter application registry.
    consumer_key='kZCO5WpquMV91pogSohU2A',
    consumer_secret='433lGvyWDpkziQwCGNIkFi38v7JQN0skxkkruGa7MA')


def admins_only(f):  #{{{
    @wraps(f)
    def decorated_function(*args, **kwargs):
        print g.user, app.admins
        if g.user is None or g.user['name'] not in app.admins:
import config



app=Flask('RefinderRecommender')
app.secret_key='veryverysecret'

from jinja2 import contextfilter, Markup


oauth=OAuth()
refinder = oauth.remote_app('refinder',
    base_url='http://getrefinder.com/',
    request_token_url='http://www.getrefinder.com/oauth/request_token',
    access_token_url='http://www.getrefinder.com/oauth/access_token',
    authorize_url='http://www.getrefinder.com/oauth/authorize',
    consumer_key=config.consumer_key,
    consumer_secret=config.consumer_secret
)

@refinder.tokengetter
def get_refinder_token():
    return session.get('refinder_token')

@app.route("/")
def index(): 
    if session.get('refinder_token',False): 
        return render_template("user.html", user=session["refinder_user"])
    else: 
        return render_template("index.html")
Exemple #14
0
from urlparse import parse_qs

from flask import request, session, redirect, render_template, flash, url_for, json
from flaskext.oauth import OAuth, OAuthException # OAuth 1.0a

from lastuserapp import app
from lastuserapp.models import db, UserExternalId, UserEmail, User
from lastuserapp.views import get_next_url, login_internal, register_internal
from lastuserapp.utils import valid_username, get_gravatar_md5sum

# OAuth 1.0a handlers
oauth = OAuth()
twitter = oauth.remote_app('twitter',
    base_url='https://api.twitter.com/1/',
    request_token_url='https://api.twitter.com/oauth/request_token',
    access_token_url='https://api.twitter.com/oauth/access_token',
    authorize_url='https://api.twitter.com/oauth/authenticate',
    consumer_key=app.config.get('OAUTH_TWITTER_KEY'),
    consumer_secret=app.config.get('OAUTH_TWITTER_SECRET'),
)

def get_extid_token(service):
    useridinfo = session.get('userid_external')
    if useridinfo:
        if service != useridinfo.get('service'):
            return None
        extid = UserExternalId.query.filter_by(service=service, userid=useridinfo['userid']).first()
        if extid:
            return {'oauth_token': extid.oauth_token,
                    'oauth_token_secret': extid.oauth_token_secret}
    return None
Exemple #15
0
# -*- coding: utf-8 -*-
"""
    :Authors: - qweqwe
"""

from flask import Flask, session, request, url_for, flash, redirect
from flaskext.oauth import OAuth
from .config import DefaultConfig as conf

oauth = OAuth()

facebook = oauth.remote_app('facebook',
    base_url            ='https://graph.facebook.com/',
    request_token_url   = None,
    authorize_url       ='https://www.facebook.com/dialog/oauth',
    access_token_url    ='/oauth/access_token',
    consumer_key        = conf.FACEBOOK_APP_ID,
    consumer_secret     = conf.FACEBOOK_APP_SECRET,
    request_token_params= {'scope': 'email'}
)

twitter = oauth.remote_app('twitter',
    base_url          ='http://api.twitter.com/1/',
    request_token_url ='http://api.twitter.com/oauth/request_token',
    authorize_url     ='http://api.twitter.com/oauth/authenticate',
    access_token_url  ='http://api.twitter.com/oauth/access_token',
    consumer_key      = conf.TWITTER_CONSUMER_KEY,
    consumer_secret   = conf.TWITTER_CONSUMER_SECRET,
)

@twitter.tokengetter
Exemple #16
0
from flaskext.oauth import OAuth
import config
import bleach
import markdown

app = Flask("index")
app.config.from_object(config)
app.secret_key = config.SECRET
mongo = PyMongo(app)
oauth = OAuth()

twitter = oauth.remote_app('KittyCheck',
    consumer_key=config.TWITTER["consumer_key"],
    consumer_secret=config.TWITTER["consumer_secret"],

    base_url='http://api.twitter.com/1/',
    request_token_url='http://api.twitter.com/oauth/request_token',
    access_token_url='http://api.twitter.com/oauth/access_token',
    authorize_url='http://api.twitter.com/oauth/authenticate',
)

def jsonify(hash, callback = None):
    if hash.has_key('_id'):
        del hash['_id']
    res = simplejson.dumps(hash, ensure_ascii=False)
    if callback:
        res = callback + '(' + res + ');'
    return Response(
            res,
            mimetype='text/javascript'
    )
Exemple #17
0
TEST_USER = None

# open app instance
app = fl.Flask(__name__)
app.debug = DEBUG
app.secret_key = SECRET_KEY

# open datastore instance (threadsafe)
ds = data.DataStore()

# set up oauth authentication with twitter
oauth = OAuth()
twitter = oauth.remote_app('twitter',
    base_url='http://api.twitter.com/1/',
    request_token_url='http://api.twitter.com/oauth/request_token',
    access_token_url='http://api.twitter.com/oauth/access_token',
    authorize_url='http://api.twitter.com/oauth/authenticate',
    consumer_key='QzW7VFbwH2uhUrVqdtwrA',
    consumer_secret='Wxij3J8N0jkcDoCBVRPxPGEsm1JXw4JUY27atr4ZjE')

def put(attrs, obj_type=None):
    '''write an object in dictionary representation to datastore'''
    if obj_type:
        attrs['type'] = obj_type
    obj = data.parse_obj(attrs)
    # ensure current user is author of new revision
    if hasattr(obj, 'author'):
        obj.author = fl.g.user.key
    key = ds.put(obj)
    return key.id() if key else ''
Exemple #18
0
from flaskext.oauth import OAuth

from calendar import timegm
import os, datetime

# setup code
app = Flask(__name__)
app.secret_key = "pagerduty"

oauth = OAuth()

facebook = oauth.remote_app(
    "facebook",
    base_url="https://graph.facebook.com/",
    request_token_url=None,
    access_token_url="/oauth/access_token",
    authorize_url="https://www.facebook.com/dialog/oauth",
    consumer_key="187344811378870",
    consumer_secret="7f75c822a976c064f479e4fe93c68d9d",
    request_token_params={"scope": "read_stream"},
)

##Conventions I will be using:
# g.user is the oauth access token
# access_token is the key (for dicts) that I will be using to store the
# access token under.

####Load from cookie


@app.before_request
def before_request():
Exemple #19
0
from flask import Flask, redirect, url_for, session, request, render_template
from flaskext.oauth import OAuth
import json
from config import *

app = Flask(__name__)
app.secret_key = 'abcdeghji'
app.debug = True
oauth = OAuth()

facebook = oauth.remote_app('facebook',
    base_url=BASE_URL,
    request_token_url=REQUEST_TOKEN_URL,
    access_token_url=ACCESS_TOKEN_URL,
    authorize_url=AUTHORIZE_URL,
    consumer_key=CONSUMER_KEY,
    consumer_secret=CONSUMER_SECRET,
    request_token_params={'scope': 'email, user_about_me, friends_about_me, \
                                    user_photos, friends_photos'},
)

@app.route('/', methods=['GET', 'POST'])
def index():
    return redirect(url_for('login'))
    
def _flame(boy, girl):
    length = len(boy) + len(girl)
    f = []
    f = list('flame')
    a = list(boy)
    b = list(girl)
Exemple #20
0
REDIRECT_URI = '/authorized'  # one of the Redirect URIs from Google APIs console

SECRET_KEY = 'development key'
DEBUG = True

app = Flask(__name__)
app.debug = DEBUG
app.secret_key = SECRET_KEY
oauth = OAuth()

google = oauth.remote_app('google',
                          base_url='https://www.google.com/accounts/',
                          authorize_url='https://accounts.google.com/o/oauth2/auth',
                          request_token_url=None,
                          request_token_params={'scope': 'https://www.googleapis.com/auth/userinfo.email',
                                                'response_type': 'code'},
                          access_token_url='https://accounts.google.com/o/oauth2/token',
                          access_token_method='POST',
                          access_token_params={'grant_type': 'authorization_code'},
                          consumer_key=GOOGLE_CLIENT_ID,
                          consumer_secret=GOOGLE_CLIENT_SECRET)

@app.route('/')
def index():
    access_token = session.get('access_token')
    if access_token is None:
        return redirect(url_for('login'))

    access_token = access_token[0]
    from urllib2 import Request, urlopen, URLError
Exemple #21
0
                    db.put(user)
            else:
                user.delete_remember_token()
                db.put(user)

    g.twitter_api_key = config.consumer_key

########################################################
# OAuth
########################################################

oauth = OAuth()
twitter = oauth.remote_app('twitter',
    base_url            = 'http://api.twitter.com/1/',
    request_token_url   = 'http://api.twitter.com/oauth/request_token',
    access_token_url    = 'http://api.twitter.com/oauth/access_token',
    authorize_url       = 'http://api.twitter.com/oauth/authenticate',
    consumer_key        = config.consumer_key,
    consumer_secret     = config.consumer_secret
)

@twitter.tokengetter
def get_twitter_token():
    user = g.user
    if user is not None:
        return user.oauth_token, user.oauth_secret
    return None

@app.route('/login')
def login():
    return twitter.authorize(callback=url_for('oauth_authorized',
        next=request.args.get('next') or request.referrer or None))
Exemple #22
0
DEBUG = False
FACEBOOK_APP_ID = "460067924007727"
FACEBOOK_APP_SECRET = "dfc9a61d4cfb96e81628b12d0f7f761a"

app.config.from_object(__name__)
db.init_app(app)
app.test_request_context().push()
db.create_all()

# set up OAuth
oauth = OAuth()
facebook = oauth.remote_app("facebook",
	base_url="https://graph.facebook.com/",
	request_token_url=None,
	access_token_url="/oauth/access_token",
	authorize_url="https://www.facebook.com/dialog/oauth",
	consumer_key=FACEBOOK_APP_ID,
	consumer_secret=FACEBOOK_APP_SECRET,
	request_token_params={"scope": "email"}
)

# set up the login manager
login_manager = LoginManager()
login_manager.login_view = "login"
login_manager.refresh_view = "reauth"

@login_manager.user_loader
def load_user(id):
	return User.get_by_id(id)

@login_manager.token_loader
Exemple #23
0

# these values are from https://www.dropbox.com/developers/apps
DROPBOX_APP_KEY = '<YOUR-APP-KEY>'
DROPBOX_APP_SECRET = '<YOUR-APP-SECRET>'


app = Flask(__name__)
app.debug = True
app.secret_key = 'secret-key-of-this-flask-app'

oauth = OAuth()
dropbox = oauth.remote_app('dropbox',
                           base_url='https://api.dropbox.com/1/',
                           request_token_url='https://api.dropbox.com/1/oauth/request_token',
                           authorize_url='https://www.dropbox.com/1/oauth/authorize',
                           access_token_url='https://api.dropbox.com/1/oauth/access_token',
                           access_token_method='POST',
                           consumer_key=DROPBOX_APP_KEY,
                           consumer_secret=DROPBOX_APP_SECRET)


@app.route('/')
def index():
    token_and_secret = session.get('token_and_secret')
    if token_and_secret is None:
        return redirect(url_for('login'))

    app.logger.debug('dropbox_uid: %s', session.get('dropbox_uid'))
    app.logger.debug('token_and_secret: %s', token_and_secret)

    resp = dropbox.get('account/info')
Exemple #24
0
from functools import wraps
from flaskext.oauth import OAuth
from flask import session
from flask import redirect
from flask import url_for 
from flask import request

# OAuth config:
oauth = OAuth()

twitter = oauth.remote_app('twitter',
    base_url='http://api.twitter.com/1/',
    request_token_url='http://api.twitter.com/oauth/request_token',
    access_token_url='http://api.twitter.com/oauth/access_token',
    authorize_url='http://api.twitter.com/oauth/authenticate',
    consumer_key='aMCIQI4nO4V1FDuGps8nRw',
    consumer_secret='EI7t8s8nefbqlpx0xcKgbitiHwn3ydpTGCWIWUsgug'
)

def login_required(f):
    @wraps(f)
    def decorated_function(*args, **kwargs):
        if session.get('twitter_user') is None:
            return redirect(url_for('login', next=request.url))
        return f(*args, **kwargs)
    return decorated_function

@twitter.tokengetter
def get_twitter_token():
    return session.get('twitter_token')
Exemple #25
0
# most of these should change for real deployment

DEBUG = True
SECRET_KEY="Eat a bag of dicks"


app = Flask(__name__)
app.config.from_object(__name__)



oauth = OAuth()
twitter = oauth.remote_app('twitter',
    base_url='http://api.twitter.com/1/',
    request_token_url='http://api.twitter.com/oauth/request_token',
    access_token_url='http://api.twitter.com/oauth/access_token',
    authorize_url='http://api.twitter.com/oauth/authenticate',
    consumer_key='kjnY7MoytSQLbv1j8BuQ', 
    consumer_secret='FHL1W0YT8M5YSNP0ze8ykGnAEvf1SMgIBDiy8ftmnU'
)

github = oauth.remote_app('github',
    base_url='http://api.github.com/',
    request_token_url= None, 
    access_token_url='https://github.com/login/oauth/access_token',
    authorize_url='https://github.com/login/oauth/authorize', 
    consumer_key='e4e50371dc552d2dcf17', 
    consumer_secret='d83b907327d29c87d0ba48ff8baea6f82b066ac1',
)


@twitter.tokengetter
Exemple #26
0
# login
#------------------------

from flaskext.oauth import OAuth
from flask import session, flash

TWITTER_APP_ID = 'PXpp9Ny0qj02sCvNfhCOg'
TWITTER_APP_SECRET = '7t7AOFecOjrlQlUP4QNLy9u8YBxzmSA13YyukobLo'
FACEBOOK_APP_ID = '399792966735734'
FACEBOOK_APP_SECRET = 'cf0cf8b405be6255c9f0fbe54133de7b'

oauth = OAuth()
twitter = oauth.remote_app('twitter',
    base_url='http://api.twitter.com/1/',
    request_token_url='http://api.twitter.com/oauth/request_token',
    access_token_url='http://api.twitter.com/oauth/access_token',
    authorize_url='http://api.twitter.com/oauth/authorize',
    consumer_key=TWITTER_APP_ID,
    consumer_secret=TWITTER_APP_SECRET
)
facebook = oauth.remote_app('facebook',
    base_url='https://graph.facebook.com/',
    request_token_url=None,
    access_token_url='/oauth/access_token',
    authorize_url='https://www.facebook.com/dialog/oauth',
    consumer_key=FACEBOOK_APP_ID,
    consumer_secret=FACEBOOK_APP_SECRET,
    request_token_params={'scope': ('email', 'user_events', 'read_stream')}
)

@twitter.tokengetter
def get_twitter_token():
Exemple #27
0
# setup flask
app = Flask(__name__)
app.debug = DEBUG
app.secret_key = SECRET_KEY
oauth = OAuth()

# Use Twitter as example remote application
twitter = oauth.remote_app(
    'twitter',
    # unless absolute urls are used to make requests, this will be added
    # before all URLs.  This is also true for request_token_url and others.
    base_url='http://api.twitter.com/1/',
    # where flask should look for new request tokens
    request_token_url='http://api.twitter.com/oauth/request_token',
    # where flask should exchange the token with the remote application
    access_token_url='http://api.twitter.com/oauth/access_token',
    # twitter knows two authorizatiom URLs.  /authorize and /authenticate.
    # they mostly work the same, but for sign on /authenticate is
    # expected because this will give the user a slightly different
    # user interface on the twitter side.
    authorize_url='http://api.twitter.com/oauth/authenticate',
    # the consumer keys from the twitter application registry.
    consumer_key='xBeXxg9lyElUgwZT6AZ0A',
    consumer_secret='aawnSpNTOVuDCjx7HMh6uSXetjNN8zWLpZwCEU4LBrk')

# setup sqlalchemy
engine = create_engine(DATABASE_URI)
db_session = scoped_session(
    sessionmaker(autocommit=False, autoflush=False, bind=engine))
Base = declarative_base()
Base.query = db_session.query_property()
Exemple #28
0
from hubology import geocode_location


@app.route('/sign-in')
@templated('sign-in.html')
def sign_in():
    return dict()


#Setup OAuth remote apps
oauth = OAuth()

twitter = oauth.remote_app(
    'twitter',
    base_url='http://api.twitter.com/1/',
    request_token_url='http://api.twitter.com/oauth/request_token',
    access_token_url='http://api.twitter.com/oauth/access_token',
    authorize_url='http://api.twitter.com/oauth/authenticate',
    consumer_key=app.config['TWITTER_CONSUMER_KEY'],
    consumer_secret=app.config['TWITTER_CONSUMER_SECRET'])

linkedin = oauth.remote_app(
    'linkedin',
    base_url='https://api.linkedin.com/',
    request_token_url='https://api.linkedin.com/uas/oauth/requestToken',
    access_token_url='https://api.linkedin.com/uas/oauth/accessToken',
    authorize_url='https://www.linkedin.com/uas/oauth/authorize',
    consumer_key=app.config['LINKEDIN_CONSUMER_KEY'],
    consumer_secret=app.config['LINKEDIN_CONSUMER_SECRET'])

#This code was written prior to flask-oauth being updated
#to support Facebook.  Need to revisit this and sync with the
Exemple #29
0
from flask import Module, url_for, render_template, request, redirect,\
                  session, g, flash
from flaskext.oauth import OAuth
import models
from forms import TodoForm

views = Module(__name__, 'views')
oauth = OAuth()
twitter = oauth.remote_app('twitter',
    base_url='http://api.twitter.com/1/',
    # where flask should look for new request tokens
    request_token_url='http://api.twitter.com/oauth/request_token',
    # where flask should exchange the token with the remote application
    access_token_url='http://api.twitter.com/oauth/access_token',
    # twitter knows two authorizatiom URLs.  /authorize and /authenticate.
    # they mostly work the same, but for sign on /authenticate is
    # expected because this will give the user a slightly different
    # user interface on the twitter side.
    #authorize_url='http://api.twitter.com/oauth/authenticate',
    authorize_url='https://api.twitter.com/oauth/authorize',
    consumer_key='qbAWqQcTBtOxPqbTh5Uag',
    consumer_secret='TdKlsHpqaSzVfZircnOEoANdsylCskNsgQcvJNMqfk'
)

@twitter.tokengetter
def get_twitter_token():
    """This is used by the API to look for the auth token and secret
    it should use for API calls.  During the authorization handshake
    a temporary set of token and secret is used, but afterwards this
    function has to return the token and secret.  If you don't want
    to store this in the database, consider putting it into the
Exemple #30
0
# -*- coding: utf-8 -*-
"""
rdrei.utils.oauth
~~~~~~~~~~~~~~~~~

Provides an oauth connector for twitter and possibly other services in the
future.

:copyright: 2010, Pascal Hartig <*****@*****.**>
:license: GPL v3, see doc/LICENSE for more details.
"""

from flaskext.oauth import OAuth
from flask import session
from rdrei import settings

oauth = OAuth()

twitter = oauth.remote_app('twitter',
    base_url='http://api.twitter.com/1/',
    request_token_url='http://api.twitter.com/oauth/request_token',
    access_token_url='http://api.twitter.com/oauth/access_token',
    authorize_url='http://api.twitter.com/oauth/authenticate',
    consumer_key=settings.TWITTER_API_KEY,
    consumer_secret=settings.TWITTER_SECRET_KEY)


@twitter.tokengetter
def get_twitter_token():
    return session.get('twitter_token')
Exemple #31
0
from flaskext.oauth import OAuth

from calendar import timegm
import os, datetime

#setup code
app = Flask(__name__)
app.secret_key = 'pagerduty'

oauth = OAuth()

facebook = oauth.remote_app(
    'facebook',
    base_url='https://graph.facebook.com/',
    request_token_url=None,
    access_token_url='/oauth/access_token',
    authorize_url='https://www.facebook.com/dialog/oauth',
    consumer_key='187344811378870',
    consumer_secret='7f75c822a976c064f479e4fe93c68d9d',
    request_token_params={'scope': 'read_stream'})

##Conventions I will be using:
#g.user is the oauth access token
#access_token is the key (for dicts) that I will be using to store the
#access token under.

####Load from cookie


@app.before_request
def before_request():
Exemple #32
0
app.config['DEBUG'] = True
SECRET_KEY = 'development key'
#app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://*****:*****@ec2-23-23-234-187.compute-1.amazonaws.com/resource44881'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///testdb.sqlite'
db = flask.ext.sqlalchemy.SQLAlchemy(app)
TWITTER_APP_ID = '8YsjtlJjL8kRaGDv1SZjmQ'
TWITTER_APP_SECRET_ID = 'QVAWDUstIpIHWhZegr5CqQm1XJHWtBIzOacQdXzP7o'

app.secret_key = SECRET_KEY
oauth = OAuth()

twitter = oauth.remote_app(
    'twitter',
    base_url='http://api.twitter.com/1/',
    request_token_url='https://api.twitter.com/oauth/request_token',
    access_token_url='https://api.twitter.com/oauth/access_token',
    authorize_url='https://api.twitter.com/oauth/authorize',
    #authorize_url='http://api.twitter.com/oauth/authenticate',
    consumer_key=TWITTER_APP_ID,
    consumer_secret=TWITTER_APP_SECRET_ID)


# User Table Exception and Validation handling
class userValidation(Exception):
    pass


# Star Table Exception and Validation handling
class starValidation(Exception):
    pass
Exemple #33
0
        logger.addHandler(handler)

# uncomment this to enable sqlalchemy logging
#logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
#logging.getLogger('sqlalchemy.orm.unitofwork').setLevel(logging.DEBUG)

twitter = oauth.remote_app(
    'twitter',
    # unless absolute urls are used to make requests, this will be added
    # before all URLs.  This is also true for request_token_url and others.
    base_url='http://api.twitter.com/1/',
    # where flask should look for new request tokens
    request_token_url='https://api.twitter.com/oauth/request_token',
    # where flask should exchange the token with the remote application
    access_token_url='https://api.twitter.com/oauth/access_token',
    # twitter knows two authorizatiom URLs.  /authorize and /authenticate.
    # they mostly work the same, but for sign on /authenticate is
    # expected because this will give the user a slightly different
    # user interface on the twitter side.
    authorize_url='https://api.twitter.com/oauth/authenticate',
    # the consumer keys from the twitter application registry.
    consumer_key=config.CONSUMER_KEY,
    consumer_secret=config.CONSUMER_SECRET,
    #    consumer_key='foa0YuAxJTiHHmaUlN5Q',
    #    consumer_secret='dzQjFTp3X69JXHoGthg2XfjCrdQ8waOlvXq6igbXmQ'
)


@twitter.tokengetter
def get_twitter_token():
    """This is used by the API to look for the auth token and secret
    it should use for API calls.  During the authorization handshake
Exemple #34
0
SECRET_KEY = 'sirl1@$l9oz%x&32l0cv8n0^s9fw8r$!cll5yto0ih_hd+eqs!(y%pypins'
DEBUG_TB_INTERCEPT_REDIRECTS = False
DEBUG=True

# flask
app = Flask(__name__)
app.debug = DEBUG
app.secret_key = SECRET_KEY
toolbar = DebugToolbarExtension(app)
oauth = OAuth()

# The Twitter
twitter = oauth.remote_app('twitter',
	base_url='http://api.twitter.com/1/',
	request_token_url='http://api.twitter.com/oauth/request_token',
	access_token_url='http://api.twitter.com/oauth/access_token',
	authorize_url='http://api.twitter.com/oauth/authenticate',
	consumer_key='YoreesqTapnna5BAxFLW7A',
	consumer_secret='ofaemfTp6qdHjaOSSqF5EvWuw7C46wCwzvAr0nwhc'
)

# sqlalchemy
engine = create_engine(DATABASE_URI)
db_session = scoped_session(sessionmaker(autocommit=False, autoflush=False, bind=engine))
Base = declarative_base()
Base.query = db_session.query_property()

def init_db():
    Base.metadata.create_all(bind=engine)

class User(Base):
	__tablename__ = 'users'
Exemple #35
0
SECRET_KEY = 'development key'
DEBUG = True

app = Flask(__name__)
app.debug = DEBUG
app.secret_key = SECRET_KEY
oauth = OAuth()

google = oauth.remote_app(
    'google',
    base_url='https://www.google.com/accounts/',
    authorize_url='https://accounts.google.com/o/oauth2/auth',
    request_token_url=None,
    request_token_params={
        'scope': 'https://www.googleapis.com/auth/userinfo.email',
        'response_type': 'code'
    },
    access_token_url='https://accounts.google.com/o/oauth2/token',
    access_token_method='POST',
    access_token_params={'grant_type': 'authorization_code'},
    consumer_key=GOOGLE_CLIENT_ID,
    consumer_secret=GOOGLE_CLIENT_SECRET)


@app.route('/')
def index():
    access_token = session.get('access_token')
    if access_token is None:
        return redirect(url_for('login'))

    access_token = access_token[0]
Exemple #36
0
from hubology.models import HubUser
from hubology import geocode_location

@app.route('/sign-in')
@templated('sign-in.html')
def sign_in():
    return dict()

#Setup OAuth remote apps
oauth = OAuth()

twitter = oauth.remote_app('twitter',
    base_url='http://api.twitter.com/1/',
    request_token_url='http://api.twitter.com/oauth/request_token',
    access_token_url='http://api.twitter.com/oauth/access_token',
    authorize_url='http://api.twitter.com/oauth/authenticate',    
    consumer_key=app.config['TWITTER_CONSUMER_KEY'],
    consumer_secret=app.config['TWITTER_CONSUMER_SECRET']
)

linkedin = oauth.remote_app('linkedin',
    base_url='https://api.linkedin.com/',
    request_token_url='https://api.linkedin.com/uas/oauth/requestToken',
    access_token_url='https://api.linkedin.com/uas/oauth/accessToken',
    authorize_url='https://www.linkedin.com/uas/oauth/authorize',    
    consumer_key=app.config['LINKEDIN_CONSUMER_KEY'],
    consumer_secret=app.config['LINKEDIN_CONSUMER_SECRET']
)

#This code was written prior to flask-oauth being updated 
#to support Facebook.  Need to revisit this and sync with the 
Exemple #37
0
import secrets


DEBUG = True


app = Flask(__name__)
app.debug = DEBUG
app.secret_key = secrets.SECRET_KEY
oauth = OAuth()


github = oauth.remote_app('github',
    base_url='https://api.github.com',
    request_token_url=None,
    access_token_url='https://github.com/login/oauth/access_token',
    authorize_url='https://github.com/login/oauth/authorize',
    consumer_key='e149164fb1f47b192df6',
    consumer_secret=secrets.GITHUB_CLIENT_SECRET,
)


@app.route('/')
def home():
    if not get_github_oauth_token():
        return redirect(url_for('login') + '?next=' + url_for('home'))
    return render_template('home.html', github_user=session.get('github_user'))


@app.route('/api')
def api():
    if not get_github_oauth_token():
Exemple #38
0
warnings.filterwarnings('ignore', category=SAWarning)
import logging

from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from flaskext.oauth import OAuth
import certifi

from nomenklatura import default_settings

logging.basicConfig(level=logging.DEBUG)

app = Flask(__name__)
app.config.from_object(default_settings)
app.config.from_envvar('NOMENKLATURA_SETTINGS', silent=True)

db = SQLAlchemy(app)

oauth = OAuth()
github = oauth.remote_app('github',
        base_url='https://github.com/login/oauth/',
        authorize_url='https://github.com/login/oauth/authorize',
        request_token_url=None,
        access_token_url='https://github.com/login/oauth/access_token',
        consumer_key=app.config.get('GITHUB_CLIENT_ID'),
        consumer_secret=app.config.get('GITHUB_CLIENT_SECRET'))

github._client.ca_certs = certifi.where()


Exemple #39
0
	APP_DOMAIN = 'http://socialchair.me'
	FACEBOOK_APP_NAME = 'SocialChair'
	FACEBOOK_APP_ID = '353832784698867'
	FACEBOOK_APP_SECRET = '321ac2425cc45427b9a795a116965026'
else:
	APP_DOMAIN = 'http://localhost:5000'
	FACEBOOK_APP_NAME = 'SocialChair_'
	FACEBOOK_APP_ID = '441691665874832'
	FACEBOOK_APP_SECRET = '828a3383ef382beb87fdacedb32523ae'

oauth = OAuth()
facebook = oauth.remote_app('facebook',
	base_url='https://graph.facebook.com/',
	request_token_url=None,
	access_token_url='/oauth/access_token',
	authorize_url='https://www.facebook.com/dialog/oauth',
	consumer_key=FACEBOOK_APP_ID,
	consumer_secret=FACEBOOK_APP_SECRET,
	request_token_params={'scope': ('email, user_actions.music, friends_actions.music, create_event, user_events')}
)

graphmuse_api_base_url = 'https://api.graphmuse.com:8081/clusters?merging=2&auth='

#----------------------------------------
# authentication and login
#----------------------------------------

def pop_all_login_credentials_from_session():
	session.pop('logged_in', None)
	session.pop('facebook_token', None)
	session.pop('facebook_id', None)
# ----------------------------------------
from flaskext.oauth import OAuth
import conf

oauth = OAuth()
# Use Twitter as example remote application
twitter = oauth.remote_app('twitter',
    # unless absolute urls are used to make requests, this will be added
    # before all URLs.  This is also true for request_token_url and others.
    base_url='http://api.twitter.com/1/',
    # where flask should look for new request tokens
    request_token_url='http://api.twitter.com/oauth/request_token',
    # where flask should exchange the token with the remote application
    access_token_url='http://api.twitter.com/oauth/access_token',
    # twitter knows two authorizatiom URLs.  /authorize and /authenticate.
    # they mostly work the same, but for sign on /authenticate is
    # expected because this will give the user a slightly different
    # user interface on the twitter side.
    authorize_url='http://api.twitter.com/oauth/authenticate',
    # the consumer keys from the twitter application registry.
    consumer_key=conf.consumer_key,
    consumer_secret=conf.consumer_secret
)

# ----------------------------------------

from google.appengine.ext import db

class User(db.Model):
    name = db.StringProperty()
Exemple #41
0
SECRET_KEY = 'development key'
DEBUG = True
FACEBOOK_APP_ID = os.environ.get('FACEBOOK_APP_ID')
FACEBOOK_APP_SECRET = os.environ.get('FACEBOOK_APP_SECRET')


app = Flask(__name__, static_folder='static', template_folder='templates')
app.debug = DEBUG
app.secret_key = SECRET_KEY
oauth = OAuth()

facebook = oauth.remote_app('facebook',
	base_url='https://graph.facebook.com/',
	request_token_url=None,
	access_token_url='/oauth/access_token',
	authorize_url='https://www.facebook.com/dialog/oauth',
	consumer_key=FACEBOOK_APP_ID,
	consumer_secret=FACEBOOK_APP_SECRET,
	request_token_params={'scope': 'email'}
)

def authenticated(func):
	def with_logging(*args, **kwargs):
		print func.__name__ + " was called"
		if not get_facebook_oauth_token():
			return redirect(url_for('login'))
		return func(*args, **kwargs)
	return with_logging


@app.route('/')
Exemple #42
0
from flask import Module, url_for, render_template, request, redirect,\
                  session, g, flash
from flaskext.oauth import OAuth
import models
from forms import TodoForm

views = Module(__name__, 'views')
oauth = OAuth()
twitter = oauth.remote_app(
    'twitter',
    base_url='http://api.twitter.com/1/',
    # where flask should look for new request tokens
    request_token_url='http://api.twitter.com/oauth/request_token',
    # where flask should exchange the token with the remote application
    access_token_url='http://api.twitter.com/oauth/access_token',
    # twitter knows two authorizatiom URLs.  /authorize and /authenticate.
    # they mostly work the same, but for sign on /authenticate is
    # expected because this will give the user a slightly different
    # user interface on the twitter side.
    #authorize_url='http://api.twitter.com/oauth/authenticate',
    authorize_url='https://api.twitter.com/oauth/authorize',
    consumer_key='qbAWqQcTBtOxPqbTh5Uag',
    consumer_secret='TdKlsHpqaSzVfZircnOEoANdsylCskNsgQcvJNMqfk')


@twitter.tokengetter
def get_twitter_token():
    """This is used by the API to look for the auth token and secret
    it should use for API calls.  During the authorization handshake
    a temporary set of token and secret is used, but afterwards this
    function has to return the token and secret.  If you don't want