Reputation: 383
I have installed facebook module in python through console
pip install facebook-sdk
then registered to facebook api to get app_id and app_secret.I am not disclosing them below.
import facebook
app_id = '00000'
app_secret = 'xxxx'
access_token = facebook.get_app_access_token(app_id,app_secret)
when i execute it to get access_token, my python console throws the following error:
Traceback (most recent call last):
File "<ipython-input-18-0dfc0fd92367>", line 1, in <module>
access_token = facebook.get_app_access_token(app_id,app_secret)
AttributeError: 'module' object has no attribute 'get_app_access_token'
please help.
Upvotes: 0
Views: 1601
Reputation: 804
This is a known Problem. Just uninstall facebook
and facebook-sdk
and then reinstall only facebook-sdk
.
sudo pip uninstall facebook
sudo pip uninstall facebook-sdk
sudo pip install facebook-sdk
Furthermore you can implement your own get_app_access_token
by:
def get_app_access_token(app_id, app_secret):
"""Get the access_token for the app.
This token can be used for insights and creating test users.
@arg app_id :type string :desc retrieved from the developer page
@arg app_secret :type string :desc retrieved from the developer page
Returns the application access_token.
"""
# Get an app access token
args = {'grant_type': 'client_credentials',
'client_id': app_id,
'client_secret': app_secret}
f = urllib2.urlopen("https://graph.facebook.com/oauth/access_token?" +
urllib.urlencode(args))
try:
result = f.read().split("=")[1]
finally:
f.close()
return result
Result will have your access token.
Upvotes: 5