I'm trying to implement a very basic Oauth transaction script (this one, to be exact: http://requests-oauthlib.readthedocs.org/en/latest/examples/facebook.html) to communicate with facebook and get user information for user profiles.
Most resources I've looked at, including the facebook docs themselves, have said that default access request includes permissions for "public_profile", which includes things like "firstname", "lastname", "gender", "age", etc. Maybe not those things exactly, but nonetheless, a lot of things.
However, every time I make the transaction, all I get is "name" and "id". Its all I can ever get, even with trying different routes on graph.facebook.com. Even weirder, when I'm asked permission in the OAuth access window, I can see that its asking for permissions for 'email' and 'public_profile'.
I cannot find anyone else having this problem and I have no idea what is wrong. Please help. Here is my exact code:
from requests_oauthlib import OAuth2Session
from requests_oauthlib.compliance_fixes import facebook_compliance_fix
# Credentials you get from registering a new application
client_id = '<id>'
client_secret = '<secret>'
# OAuth endpoints given in the Facebook API documentation
authorization_base_url = 'https://www.facebook.com/dialog/oauth'
token_url = 'https://graph.facebook.com/oauth/access_token'
redirect_uri = 'https://localhost:8080/' # Should match Site URL
scope = [
"email"
]
facebook = OAuth2Session(client_id, scope=scope, redirect_uri=redirect_uri)
facebook = facebook_compliance_fix(facebook)
# Redirect user to Facebook for authorization
authorization_url, state = facebook.authorization_url(authorization_base_url)
print 'Please go here and authorize,', authorization_url
# Get the authorization verifier code from the callback url
redirect_response = raw_input('Paste the full redirect URL here:')
# Fetch the access token
print "\naccess token: "
print facebook.fetch_token(
token_url,
client_secret=client_secret,
authorization_response=redirect_response
)
print "\n"
# Fetch a protected resource, i.e. user profile
r = facebook.get('https://graph.facebook.com/me')
print r.content