I am trying to use twitter's 3-legged OAuth to tweet using a twitter bot that I made, on a different twitter account. After going through the tweepy documentation (https://docs.tweepy.org/en/stable/authentication.html#legged-oauth) for 3-legged OAuth, I ended up with the following code:
import tweepy
consumer_key = 'XMNB5a0cuHOrko2ETCqs8iT4p'
consumer_secret = 'm46XTiR9JkYXWEoHWZwyemQJ5V5JW448KzovQWnpWNglTVUmjz'
callback_url = 'http://127.0.0.1/'
oauth1_user_handler = tweepy.OAuth1UserHandler(
consumer_key, consumer_secret,
callback= callback_url
)
print(oauth1_user_handler.get_authorization_url())
After printing the URL to grant the bot access to my other twitter account, the website redir http://127.0.0.1/?oauth_token=IsmSagAAAAABhOTpAAABg2xaxX4&oauth_verifier=QK7sVI3A8i0wsUR59s4MiGPMFJejzWcr
access_token, access_token_secret = oauth1_user_handler.get_access_token(
'QK7sVI3A8i0wsUR59s4MiGPMFJejzWcr'
)
Next I passed the end of the URL into this portion of the code, where it asks for the OAuth Verifier. When I run this, I get an error.
"raise TweepyException(e)
tweepy.errors.TweepyException: Token request failed with code 401, response was 'Error processing your OAuth request: Invalid oauth_verifier parameter'."
I'm not sure what I am doing wrong here or what the issue. If anyone has an experience with this or 3-legged OAuth or any other suggestions on how to tweet on a different account, any help would be greatly appreciated, thanks!