'Can't generate facebook access token
I need to generate the Facebook access token for a project. Code:
import requests
import json
url = 'https://graph.facebook.com/oauth/access_token'
payload = {
'grant_type': 'client_credentials',
'client_id': 'clientid',
'client_secret': 'secret'
}
response = requests.post(url, json=payload)
print (response.json()['access_token'])
What I'm getting as output is my id|type, after research I found that it is due to the 'client_credential' request. I need to generate access tokens for a project (I want to use them to find likes etc). Any help would be appreciated, it's my first time attempting a project like this.
Solution 1:[1]
use [facebook-sdk.][1]
import facebook
app_id = 'YOUR_APP_ID'
app_secret = 'YOUR_APP_SECRET'
graph = facebook.GraphAPI()
# exactly what you're after ;-)
access_token = graph.get_app_access_token(app_id, app_secret)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Abdur Raihan |