Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token params seem to be ignored when using app_key to initialize the remote app #55

Closed
jon301 opened this issue Nov 20, 2013 · 4 comments

Comments

@jon301
Copy link

commented Nov 20, 2013

Hello,

Here is an example of a signin with Facebook where the email scope is ignored :

from flask import Flask, redirect, url_for, session, request
from flask_oauthlib.client import OAuth


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

app.config['OAUTH_FACEBOOK'] = {
    'consumer_key': '',
    'consumer_secret': '',
    'request_token_params': {'scope': 'email'},
    'base_url': 'https://graph.facebook.com',
    'request_token_url': None,
    'access_token_url': '/oauth/access_token',
    'authorize_url': 'https://www.facebook.com/dialog/oauth',
}

facebook = oauth.remote_app(
    'facebook',
    app_key='OAUTH_FACEBOOK'
)


@app.route('/')
def index():
    return redirect(url_for('login'))


@app.route('/login')
def login():
    return facebook.authorize(callback=url_for('facebook_authorized',
        next=request.args.get('next') or request.referrer or None,
        _external=True))


@app.route('/login/authorized')
@facebook.authorized_handler
def facebook_authorized(resp):
    if resp is None:
        return 'Access denied: reason=%s error=%s' % (
            request.args['error_reason'],
            request.args['error_description']
        )
    session['oauth_token'] = (resp['access_token'], '')
    me = facebook.get('/me')
    return 'Logged in as id=%s name=%s redirect=%s' % \
        (me.data['id'], me.data['name'], request.args.get('next'))


@facebook.tokengetter
def get_facebook_oauth_token():
    return session.get('oauth_token')


if __name__ == '__main__':
    app.run()

Thanks for your help.

lepture added a commit that referenced this issue Nov 21, 2013

lepture added a commit that referenced this issue Nov 21, 2013

@lepture

This comment has been minimized.

Copy link
Owner

commented Nov 21, 2013

@jon301 You are right.

For now, you can put request_token_params in remote_app().

@jon301

This comment has been minimized.

Copy link
Author

commented Nov 21, 2013

Thanks

@lepture

This comment has been minimized.

Copy link
Owner

commented Nov 21, 2013

@jon301 I've written an article on creating oauth server. I would like some suggestions. http://lepture.com/en/2013/create-oauth-server

@lepture lepture closed this Nov 21, 2013

@lepture

This comment has been minimized.

Copy link
Owner

commented Nov 25, 2013

@jon301 The bugfix version: 0.4.1 is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.