当前位置: 首页>>代码示例>>Python>>正文


Python OAuth.remote_app方法代码示例

本文整理汇总了Python中flaskext.oauth.OAuth.remote_app方法的典型用法代码示例。如果您正苦于以下问题:Python OAuth.remote_app方法的具体用法?Python OAuth.remote_app怎么用?Python OAuth.remote_app使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flaskext.oauth.OAuth的用法示例。


在下文中一共展示了OAuth.remote_app方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_oauth

# 需要导入模块: from flaskext.oauth import OAuth [as 别名]
# 或者: from flaskext.oauth.OAuth import remote_app [as 别名]
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)
开发者ID:kultus,项目名称:foofind-web,代码行数:29,代码来源:user.py

示例2: get_github_oauth_client

# 需要导入模块: from flaskext.oauth import OAuth [as 别名]
# 或者: from flaskext.oauth.OAuth import remote_app [as 别名]
    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
开发者ID:shalabhaggarwal,项目名称:nereid-auth-github,代码行数:30,代码来源:user.py

示例3: OAuth

# 需要导入模块: from flaskext.oauth import OAuth [as 别名]
# 或者: from flaskext.oauth.OAuth import remote_app [as 别名]
# -*- 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
开发者ID:chopachom,项目名称:coltrane,代码行数:33,代码来源:oauth.py

示例4: OAuth

# 需要导入模块: from flaskext.oauth import OAuth [as 别名]
# 或者: from flaskext.oauth.OAuth import remote_app [as 别名]
app.config['DEBUG'] = True
SECRET_KEY = 'development key'
#app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://zoubpmfsdtxwoq:[email protected].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

开发者ID:hybridkris,项目名称:GoldStar,代码行数:31,代码来源:app.py

示例5: Flask

# 需要导入模块: from flaskext.oauth import OAuth [as 别名]
# 或者: from flaskext.oauth.OAuth import remote_app [as 别名]
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)
开发者ID:pavanmehta,项目名称:cj_flames,代码行数:33,代码来源:app.py

示例6: Blueprint

# 需要导入模块: from flaskext.oauth import OAuth [as 别名]
# 或者: from flaskext.oauth.OAuth import remote_app [as 别名]
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))
开发者ID:gcs272,项目名称:ehd,代码行数:33,代码来源:etsy.py

示例7: Flask

# 需要导入模块: from flaskext.oauth import OAuth [as 别名]
# 或者: from flaskext.oauth.OAuth import remote_app [as 别名]
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'
    )
开发者ID:jiller,项目名称:kittycheck,代码行数:33,代码来源:index.py

示例8: Blueprint

# 需要导入模块: from flaskext.oauth import OAuth [as 别名]
# 或者: from flaskext.oauth.OAuth import remote_app [as 别名]
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)
开发者ID:yukatou,项目名称:boardapp,代码行数:34,代码来源:project.py

示例9: OAuth

# 需要导入模块: from flaskext.oauth import OAuth [as 别名]
# 或者: from flaskext.oauth.OAuth import remote_app [as 别名]
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
开发者ID:ckwang,项目名称:ST,代码行数:33,代码来源:main.py

示例10: Flask

# 需要导入模块: from flaskext.oauth import OAuth [as 别名]
# 或者: from flaskext.oauth.OAuth import remote_app [as 别名]
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
开发者ID:cpdean,项目名称:flask-oauth,代码行数:32,代码来源:google.py

示例11: Flask

# 需要导入模块: from flaskext.oauth import OAuth [as 别名]
# 或者: from flaskext.oauth.OAuth import remote_app [as 别名]
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():
开发者ID:semisight,项目名称:microfilm,代码行数:34,代码来源:micro.py

示例12: Blueprint

# 需要导入模块: from flaskext.oauth import OAuth [as 别名]
# 或者: from flaskext.oauth.OAuth import remote_app [as 别名]
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:
开发者ID:aramirez92,项目名称:base_flask_project,代码行数:34,代码来源:authentication.py

示例13: get_refinder_token

# 需要导入模块: from flaskext.oauth import OAuth [as 别名]
# 或者: from flaskext.oauth.OAuth import remote_app [as 别名]
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")
开发者ID:gromgull,项目名称:py-refinder-api,代码行数:32,代码来源:RefinderApp.py

示例14: OAuth

# 需要导入模块: from flaskext.oauth import OAuth [as 别名]
# 或者: from flaskext.oauth.OAuth import remote_app [as 别名]
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
开发者ID:lifeeth,项目名称:lastuser,代码行数:33,代码来源:oauthclient.py

示例15: OAuth

# 需要导入模块: from flaskext.oauth import OAuth [as 别名]
# 或者: from flaskext.oauth.OAuth import remote_app [as 别名]
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')
开发者ID:allaud,项目名称:Sufx,代码行数:33,代码来源:oauth.py


注:本文中的flaskext.oauth.OAuth.remote_app方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。