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


Python oauth.OAuth类代码示例

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


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

示例1: init_oauth

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,代码行数:27,代码来源:user.py

示例2: get_github_oauth_client

    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,代码行数:28,代码来源:user.py

示例3: __init__

 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)
开发者ID:bandycj,项目名称:SwaRoute,代码行数:11,代码来源:oauth_methods.py

示例4: Facebook

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']
开发者ID:bandycj,项目名称:SwaRoute,代码行数:19,代码来源:oauth_methods.py

示例5: Flask

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', 
开发者ID:mementa,项目名称:mementa,代码行数:31,代码来源:oauthtest.py

示例6: Blueprint

# -*- 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()
开发者ID:yukatou,项目名称:boardapp,代码行数:31,代码来源:project.py

示例7: OAuth

# -*- 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()
开发者ID:lifeeth,项目名称:lastuser,代码行数:31,代码来源:oauthclient.py

示例8: Flask

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://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
开发者ID:hybridkris,项目名称:GoldStar,代码行数:31,代码来源:app.py

示例9: Flask

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,代码行数:31,代码来源:app.py

示例10: Blueprint

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,代码行数:31,代码来源:etsy.py

示例11: Flask

#!/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
开发者ID:semisight,项目名称:microfilm,代码行数:31,代码来源:micro.py

示例12: get_refinder_token

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(): 
开发者ID:gromgull,项目名称:py-refinder-api,代码行数:31,代码来源:RefinderApp.py

示例13: OAuth

# -*- coding: utf-8 -*-
"""
rdrei.utils.oauth
~~~~~~~~~~~~~~~~~

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

:copyright: 2010, Pascal Hartig <[email protected]>
: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')
开发者ID:passy,项目名称:rdreiflask,代码行数:30,代码来源:oauth.py

示例14: OAuth

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,
开发者ID:shea256,项目名称:headerfile.me,代码行数:31,代码来源:views.py

示例15: OAuth

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')
开发者ID:jgumbley,项目名称:beatshuffle,代码行数:30,代码来源:auth.py


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