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 #3
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)
Exemple #4
0
 def __init__(self, application_id, application_secret, dm_id):
     self.oauth = OAuth()
     self.connection = oauth.remote_app('facebook',
                                      base_url=Facebook.graphApiUrl,
                                      request_token_url=None,
                                      access_token_url='/oauth/access_token',
                                      authorize_url='https://www.facebook.com/dialog/oauth',
                                      consumer_key=application_id,
                                      consumer_secret=application_secret,
                                      request_token_params={'scope': 'email'})
     self.dm_id = dm_id
Exemple #5
0
 def __init__(self, key, secret):
     self.auth_service = OAuth().remote_app(self.method,
         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=key,
         consumer_secret=secret,
         request_token_params={'scope': 'email'}
     )
     super(Facebook, self).__init__(self.method, self.auth_service)
Exemple #6
0
class Facebook(AbstractOauthMethod):
    method = "facebook"
    auth_service = None

    def __init__(self, key, secret):
        self.auth_service = OAuth().remote_app(self.method,
            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=key,
            consumer_secret=secret,
            request_token_params={'scope': 'email'}
        )
        super(Facebook, self).__init__(self.method, self.auth_service)

    def get_user_info(self, resp):
        session['oauth_token'] = (resp['access_token'], '')
        return self.auth_service.get('/me').data['name']
Exemple #7
0
class Twitter:
    oauth = OAuth()

    def __init__(self, c_k, c_s):
        #oauth = OAuth()
        # Use Twitter as example remote application
        self.oauth = self.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=c_k,  #app.config['TWITTER_CONSUMER_KEY'], 
            consumer_secret=c_s  #app.config['TWITTER_CONSUMER_KEY']
        )
Exemple #8
0
import userPageUser
import StarObject
import page
from pythontincan import startThread
# Create the app for Flask
app = Flask(__name__)
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
from flask import redirect
from flask import url_for
from flask import request
from flask.blueprints import Blueprint
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:
Exemple #10
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 #11
0
from flaskext.oauth import OAuth

from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base

# configuration
DATABASE_URI = 'sqlite:////tmp/flask-oauth.db'
SECRET_KEY = 'development key'
DEBUG = True

# 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.
Exemple #12
0
from flaskext.oauth import OAuth


# You must configure these 3 values from Google APIs console
# https://code.google.com/apis/console
GOOGLE_CLIENT_ID = '<Client-ID>'
GOOGLE_CLIENT_SECRET = '<Client-secret>'
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():
Exemple #13
0
import base64
import os
from flaskext.oauth import OAuth

# 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', 
sys.path.append("..") # pretty!
from refinder import Refinder

import rdflib

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(): 
Exemple #15
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 #16
0
"""
Flask Module Docs:  http://flask.pocoo.org/docs/api/#flask.Module

This file is used for both the routing and logic of your
application.
"""

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'
)
Exemple #17
0
users.add_url_rule('/users/<username>/', view_func=UserDetailsView.as_view('details'))
users.add_url_rule('/users/<username>/edit', view_func=UserEditView.as_view('edit'))

#------------------------
# 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,
Exemple #18
0
import urllib
import urllib2
import logging

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',
Exemple #19
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 #20
0
# -*- coding: utf-8 -*-

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>')
Exemple #21
0
app = Flask(__name__)

SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL')#
#SQLALCHEMY_DATABASE_URI = "sqlite:///" + os.path.join(os.path.dirname(__file__), "db", "database.db")
SECRET_KEY = "RandomSecretKey"
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"
Exemple #22
0
from gfm import gfm
from forms import NewPostForm, EditPostForm, LoginForm
from pymongo.objectid import ObjectId
from functools import wraps

from pymongo import Connection
from datetime import datetime
from flaskext.oauth import OAuth

from urlparse import urljoin
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',
Exemple #23
0
#!/usr/bin/env python
from __future__ import division
from flask import Flask, render_template, url_for, session, request, g, \
    redirect, flash
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
Exemple #24
0
# -*- coding: utf-8 -*-

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()
Exemple #25
0
#  Copyright (C) 2012 André Panisson
#  You can contact me by email ([email protected]) or write to:
#  Via Alassio 11/c - 10126 Torino - Italy
#
from flask import request, redirect, url_for, session
from flaskext.oauth import OAuth
import flask, tweepy
from whatshot import config
from model import User, commit
import logging

# setup flask
app = flask.Flask(__name__)
app.debug = config.DEBUG
app.secret_key = config.SECRET_KEY
oauth = OAuth()

# add the flask log handlers to sqlalchemy
loggers = [
    logging.getLogger('sqlalchemy.engine'),
    logging.getLogger('sqlalchemy.orm.unitofwork')
]
for logger in loggers:
    for handler in app.logger.handlers:
        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(
Exemple #26
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 #27
0
    def init_app(self, app):
        if app is None: return

        blueprint = Blueprint('social', __name__)

        config = default_config.copy()
        try:
            config.update(app.config['SOCIAL'])
        except:
            pass
        app.config['SOCIAL'] = config

        # Update the service provider configurations
        social_providers_config = {}

        if 'SOCIAL_PROVIDERS' in app.config:
            for provider, provider_config in default_provider_config.items():
                if provider in app.config['SOCIAL_PROVIDERS']:
                    d_config = provider_config.copy()
                    d_oauth_config = d_config['oauth'].copy()

                    p_config = app.config['SOCIAL_PROVIDERS'][provider][
                        'oauth']
                    d_config.update(app.config['SOCIAL_PROVIDERS'][provider])
                    d_oauth_config.update(p_config)
                    d_config['oauth'] = d_oauth_config

                    social_providers_config[provider] = d_config

        app.config['SOCIAL_PROVIDERS'] = social_providers_config

        app.logger.debug('Social Configuration: %s' % app.config['SOCIAL'])
        app.logger.debug('Social Provider Configuration: '
                         '%s' % app.config['SOCIAL_PROVIDERS'])

        # Connection service name
        app.oauth = OAuth()
        app.social = self

        @blueprint.route('/login/<provider_id>', methods=['POST'])
        def login(provider_id):
            if current_user.is_authenticated():
                return redirect("/")

            callback_url = get_authorize_callback('/login/%s' % provider_id)

            current_app.logger.debug(
                'Starting login via %s account. Callback '
                'URL = %s' % (get_display_name(provider_id), callback_url))

            session['post_oauth_login_url'] = request.form.get(
                'next', current_app.config['AUTH']['post_login_view'])

            remote_app = get_remote_app(provider_id).remote_app
            return remote_app.authorize(callback_url)

        @blueprint.route('/connect/<provider_id>', methods=['POST'])
        @login_required
        def connect(provider_id):
            callback_url = get_authorize_callback('/connect/%s' % provider_id)

            current_app.logger.debug(
                'Starting process of connecting %s '
                'account to user account %s. Callback URL = %s' %
                (get_display_name(provider_id), current_user, callback_url))

            session['post_oauth_connect_url'] = request.form.get(
                'next', current_app.config['SOCIAL']['connect_allow_view'])

            remote_app = get_remote_app(provider_id).remote_app
            return remote_app.authorize(callback_url)

        @blueprint.route('/connect/<provider_id>', methods=['DELETE'])
        @login_required
        def remove_all_connections(provider_id):
            try:
                display_name = get_display_name(provider_id)

                connection_service.remove_all_connections(
                    current_user.get_id(), provider_id)

                current_app.logger.debug('Removed all connections to %s for '
                                         '%s' % (provider_id, current_user))

                flash("Connections to %s removed" % display_name)
            except:
                current_app.logger.error(
                    'Unable to remove all connections to '
                    '%s for %s' %
                    (get_display_name(provider_id), current_user))

                flash("Unabled to remove connection")
            return redirect(request.referrer)

        @blueprint.route('/connect/<provider_id>/<provider_user_id>',
                         methods=['DELETE'])
        @login_required
        def remove_connection(provider_id, provider_user_id):
            try:
                display_name = get_display_name(provider_id)

                connection_service.remove_connection(current_user.get_id(),
                                                     provider_id,
                                                     provider_user_id)

                current_app.logger.debug('Removed connection to %s for '
                                         '%s' % (provider_id, current_user))

                flash("Connection to %s removed" % display_name)
            except:
                current_app.logger.error(
                    'Unable to remove connection to %s/%s '
                    'for %s' % (get_display_name(provider_id),
                                provider_user_id, current_user))

                flash("Unabled to remove connection")

            return redirect(request.referrer)

        # Setup handlers for the configured providers
        for p_id, p_config in app.config['SOCIAL_PROVIDERS'].items():
            _configure_provider(app, blueprint, app.oauth, p_id, p_config)

        app.register_blueprint(blueprint,
                               url_prefix=app.config['SOCIAL']['url_prefix'])
Exemple #28
0
# -*- coding: utf-8 -*-

from urllib import urlencode, quote
from urllib2 import urlopen, URLError
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()
Exemple #29
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 #30
0
from flask import Module, render_template, request, redirect, url_for, session, flash, g
from flaskext.oauth import OAuth
from functools import wraps
from crowdwoo import queries

# define the remote oauth application
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='foo',
    consumer_secret='bar'
)

# define this module
auth = Module(__name__)


@auth.route('/signin')
def signin():
    return twitter.authorize(callback=url_for('oauth_authorized', next=request.args.get('next') or request.referrer or None))


@auth.route('/signout')
def signout():
    if 'user' in session:
        del(session['user'])
    return redirect(url_for('core.index'))

Exemple #31
0
#!/usr/bin/env python
from __future__ import division
from flask import Flask, render_template, url_for, session, request, g, redirect, flash
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
Exemple #32
0
from boto.s3.connection import S3Connection
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 #33
0
import userPageUser
import StarObject
import page
from pythontincan import startThread
# Create the app for Flask
app = Flask(__name__)
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
Exemple #34
0
import hashlib, simplejson, requests, random
from datetime import datetime
import time
import pymongo, bson
from flask import Flask, render_template, request, Response, redirect, abort, session, send_from_directory, g, url_for
from flask.ext.pymongo import PyMongo
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)
Exemple #35
0
from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base

# configuration
DATABASE_URI = 'sqlite:///./pypins.db'
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()
Exemple #36
0
SECRET_KEY = 'abcdef'
DEBUG = True
MAX_UP = 3
MAX_DOWN = 3
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'):
Exemple #37
0
from flaskext.login import login_user
import simplejson as json
import urllib
import urllib2
import logging

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',    
Exemple #38
0
from flask import Flask, redirect, url_for, session
from flaskext.oauth import OAuth

# You must configure these 3 values from Google APIs console
# https://code.google.com/apis/console
GOOGLE_CLIENT_ID = '<Client-ID>'
GOOGLE_CLIENT_SECRET = '<Client-secret>'
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)
Exemple #39
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 #40
0
__author__ = 'david'

import urllib, json
from flask import session
from flaskext.oauth import OAuth

oauth = OAuth()

class Facebook():
    
    graphApiUrl = 'https://graph.facebook.com/'
    
    def __init__(self, application_id, application_secret, dm_id):
        self.oauth = OAuth()
        self.connection = oauth.remote_app('facebook',
                                         base_url=Facebook.graphApiUrl,
                                         request_token_url=None,
                                         access_token_url='/oauth/access_token',
                                         authorize_url='https://www.facebook.com/dialog/oauth',
                                         consumer_key=application_id,
                                         consumer_secret=application_secret,
                                         request_token_params={'scope': 'email'})
        self.dm_id = dm_id

    def authorize(self, resp):
        access_token = resp['access_token']
        profile = self._get_profile(access_token)

        if profile["id"] == self.dm_id:
            session['dm'] = True
        elif self._is_player(access_token):
# See also: http://github.com/mitsuhiko/flask-oauth

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

from flask import Flask, redirect, url_for, session, request, render_template, abort, flash, get_flashed_messages, g
app = Flask(__name__)
#app.debug = True
# set the secret key.  keep this really secret:
app.secret_key = 'xxxxxxxxx'

# ----------------------------------------
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,
Exemple #42
0
import json

from flask import Flask, redirect, render_template, request, session, url_for
from flaskext.oauth import OAuth

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'))
Exemple #43
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 #44
0
#----------------------------------------

from flaskext.oauth import OAuth

if os.environ.get("PORT"):
	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
#----------------------------------------
Exemple #45
0
from flask import session
from flask import url_for
from flask import redirect
from flaskext.oauth import OAuth


# 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'))
Exemple #46
0
import os
from flask import Flask, redirect, url_for, session, request, render_template
from flaskext.oauth import OAuth


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'))
Exemple #47
0
"""
Flask Module Docs:  http://flask.pocoo.org/docs/api/#flask.Module

This file is used for both the routing and logic of your
application.
"""

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')