Created
July 6, 2019 14:59
-
-
Save MUGABA/fcd2a68c579e7980b9b89de70c9a2eeb to your computer and use it in GitHub Desktop.
I have an issue with connect_via
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @cust_bp.route('/api/v1/customers/facebook', methods = ['POST']) | |
| def facebook_login(): | |
| if not facebook.authorized: | |
| return redirect(url_for('facebook.login')) | |
| account_info = facebook.get('account/settings.json') | |
| account_info_json = account_info.json() | |
| return '<h1>Your facebook name is @{}'.format(account_info_json['screen_name']) | |
| @oauth_authorized.connect_via(facebook_blueprint) | |
| def facebook_logged_in(blueprint, token): | |
| account_info = blueprint.session.get('account/settings.json') | |
| if account_info.ok: | |
| account_info_json = account_info.json() | |
| username = account_info_json['screen_name'] | |
| query = Customers.query.filter_by(username=name) | |
| try: | |
| user = query.one() | |
| except NoResultFound: | |
| user = User(username=username) | |
| db.session.add(user) | |
| db.session.commit() | |
| login_user(user) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment