python
pip install facebook-sdk
python
import facebook
# your app id and app secret
app_id = 'YOUR_APP_ID'
app_secret = 'YOUR_APP_SECRET'
# create a Facebook Graph API object
graph = facebook.GraphAPI()
# get the authorization URL
auth_url = graph.get_auth_url(app_id, redirect_uri='https://your-redirect-uri.com', display='popup')
# prompt the user to visit the authorization URL and get the authorization code
# once the user grants permission, exchange the code for a long-lived access token
access_token = graph.get_access_token(app_id, app_secret, redirect_uri='https://your-redirect-uri.com', code='AUTHORIZATION_CODE')
# now you can use the access token to make API calls on behalf of the user
graph.access_token = access_token
# get the user's profile
profile = graph.get_object('/me')
# print the user's name
print(profile['name'])