Issue
I have a simple Python app with Tweepy to upload image to Twitter. This feature is available only with V1 API. The access to V1 API is possible either with Standalone App or with Elevated Privileges.
I did both of them but I constantly receive 403 Forbidden error.
Here is my simple code:
client_v1 = tweepy.API(auth=auth)
upload_file_media = client_v1.media_upload(
filename="my_image.jpg"
)
This, I tried with all 3 possible authentication methods:
auth = tweepy.OAuth2AppHandler
auth = tweepy.OAuth2BearerHandler
auth = tweepy.OAuth1UserHandler
None of them worked.
Here is the stacktrace:
File "/opt/anaconda3/envs/tf/lib/python3.7/site-packages/tweepy/api.py", line 3411, in media_upload
additional_owners=additional_owners, **kwargs
File "/opt/anaconda3/envs/tf/lib/python3.7/site-packages/tweepy/api.py", line 46, in wrapper
return method(*args, **kwargs)
File "/opt/anaconda3/envs/tf/lib/python3.7/site-packages/tweepy/api.py", line 3455, in simple_upload
upload_api=True, **kwargs
File "/opt/anaconda3/envs/tf/lib/python3.7/site-packages/tweepy/api.py", line 259, in request
raise Forbidden(resp)
tweepy.errors.Forbidden: 403 Forbidden
Any idea what could be the reason?
Thanks a lot.
Solution
I think I found a way of doing this. There is a setting "User authentication settings". Go there and activate Oauthv1. It is asking some callback URL and website URL. If you have commandline or batch job, these are unnecessary. Simply use 127.0.0.1 and localhost. Then it works. weird setting.
Answered By - selcukbeyhan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.