You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am following the facebook exmaple but when I am trying to do the same thing in other app it gives me AttributeError. I have run the facebook example in same virtualenv and its works fine but same is not happening with the other app with also have same env.
fromflaskimportBlueprint, session, render_template, flash, request, redirect, url_forfromflask.ext.loginimportlogin_user, logout_user, login_requiredfromappnameimportcachefromappname.formsimportLoginFormfromappname.modelsimportUserfromappname.settingsimportDevConfigfromrauth.serviceimportOAuth2Serviceapp_setting=DevConfig()
main=Blueprint('main', __name__)
# login through facebookgraph_url='https://graph.facebook.com/'facebook=OAuth2Service(name='facebook',
authorize_url='https://www.facebook.com/dialog/oauth',
access_token_url=graph_url+'oauth/access_token',
client_id='(removed for web)',
client_secret='(removed for web)',
base_url=graph_url)
@main.route('/')@cache.cached(timeout=1000)defhome():
returnrender_template('index.html')
@main.route("/login", methods=["GET", "POST"])deflogin():
form=LoginForm()
ifform.validate_on_submit():
iflogin_user(form.user):
session['user_id'] =form.user.idflash("Logged in successfully.", "success")
returnredirect(request.args.get("next") orurl_for(".home"))
else:
flash("Login failed.", "danger")
returnrender_template("login.html", form=form)
@main.route('/facebook')deffacebook():
redirect_uri=url_for('.authorized', _external=True)
params= {'redirect_uri': redirect_uri}
printparamsprintdir(facebook)
returnredirect(facebook.get_authorize_url(**params))
@main.route('/authorized')defauthorized():
# check to make sure the user authorized the requestifnot'code'inrequest.args:
flash('You did not authorize the request')
returnredirect('.index')
# make a request for the access token credentials using coderedirect_uri=url_for('authorized', _external=True)
data=dict(code=request.args['code'], redirect_uri=redirect_uri)
session=facebook.get_auth_session(data=data)
# the "me" responseme=session.get('me').json()
User.get_or_create(me['username'], me['id'])
flash('Logged in as '+me['name'])
returnredirect(url_for('.index'))
Traceback (most recent call last):
File "/root/.virtualenvs/codemap/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/root/.virtualenvs/codemap/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/root/.virtualenvs/codemap/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/root/.virtualenvs/codemap/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/root/.virtualenvs/codemap/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/root/.virtualenvs/codemap/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/root/.virtualenvs/codemap/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/root/.virtualenvs/codemap/lib/python2.7/site-packages/flask_debugtoolbar/__init__.py", line 125, in dispatch_request
return view_func(**req.view_args)
File "/root/geniuslocale/Flask-Foundation/appname/controllers/main.py", line 54, in facebook
return redirect(facebook.get_authorize_url(**params))
The text was updated successfully, but these errors were encountered:
I am following the facebook exmaple but when I am trying to do the same thing in other app it gives me AttributeError. I have run the facebook example in same virtualenv and its works fine but same is not happening with the other app with also have same env.
The text was updated successfully, but these errors were encountered: