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
fbconnect() in project.py isn't working as it is using v3.2 Graph API. Here's my solution that even doesn't requires local fb_client_secrets.json anymore:
@app.route('/fbconnect', methods=['POST'])
def fbconnect():
if request.args.get('state') != login_session['state']:
response = make_response(json.dumps('Invalid state parameter.'), 401)
response.headers['Content-Type'] = 'application/json'
return response
access_token = request.data
print "access token received %s " % access_token
# Use token to get user info from API
userinfo_url = "https://graph.facebook.com/me"
url = '%s?access_token=%s&fields=name,id,email,picture' % (userinfo_url, access_token)
h = httplib2.Http()
result = h.request(url, 'GET')[1]
# print "url sent for API access:%s"% url
# print "API JSON result: %s" % result
data = json.loads(result)
login_session['provider'] = 'facebook'
login_session['username'] = data["name"]
login_session['email'] = data["email"]
login_session['facebook_id'] = data["id"]
# The token must be stored in the login_session in order to properly logout
login_session['access_token'] = access_token
# Get user picture
login_session['picture'] = data["picture"]["data"]["url"]
# see if user exists
user_id = getUserID(login_session['email'])
if not user_id:
user_id = createUser(login_session)
login_session['user_id'] = user_id
output = ''
output += '<h1>Welcome, '
output += login_session['username']
output += '!</h1>'
output += '<img src="'
output += login_session['picture']
output += ' " style = "width: 300px; height: 300px;border-radius: 150px;-webkit-border-radius: 150px;-moz-border-radius: 150px;"> '
flash("Now logged in as %s" % login_session['username'])
return output
The text was updated successfully, but these errors were encountered:
oliveira-marcio
changed the title
[FIX] here's my fix to fbconnect()
[FIX] here's my fix to fbconnect() in Graph API v3.2
Oct 28, 2018
fbconnect()
inproject.py
isn't working as it is using v3.2 Graph API. Here's my solution that even doesn't requires localfb_client_secrets.json
anymore:The text was updated successfully, but these errors were encountered: