本文整理汇总了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)
示例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
示例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
示例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
示例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)
示例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))
示例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'
)
示例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)
示例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
示例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
示例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():
示例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:
示例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")
示例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
示例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')