Python Forum
Twitter authentication failure with Tweepy
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Twitter authentication failure with Tweepy

I am encountering a rather weird problem when authenticating my app with Twitter using Tweepy. Below code works like a charm on my Mac, but it fails on my NAS.

On my NAS I get this error code from the Twitter API:
[{“message”:”Could not authenticate you”,”code”:32}]
This is my code:
auth = tweepy.OAuthHandler ( apiKey, apiSecretKey )
auth.set_access_token ( accessToken, accessTokenSecret )
api = tweepy.API(auth, wait_on_rate_limit=True)
myID =
Keys, tokens and secrects are identical on both machines. I have already refreshed them once, but it doesn't help.
On my Mac I use Python 3.7. On the NAS it's Python 3.5. This is the only obvious difference that I could find, but I cannot believe that this is the reason authentication is working on one machine, but not on the other.

I use Tweepy 3.7.0.

Any ideas what could cause this?
I have dug deeper into this and enabled debug output in Tweepy. But still I am puzzled.

On my MAC (OK)
send: b'GET /1.1/account/verify_credentials.json HTTP/1.1\r\nAccept-Encoding: identity\r\nHost:\r\nAuthorization: OAuth oauth_nonce="82970471272089437891549199975", oauth_timestamp="1549199975", oauth_version="1.0", oauth_signature_method="HMAC-SHA1", oauth_consumer_key="<key>", oauth_token="<token>", oauth_signature="Rcq0xG7b1icM4WOuWqFG9HkXm4s%3D"\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'
On my NAS (not OK)
send: b'GET /1.1/account/verify_credentials.json HTTP/1.1\r\nAccept-Encoding: identity\r\nHost:\r\nAuthorization: OAuth oauth_nonce="182485988168612436021549199916", oauth_timestamp="1549199916", oauth_version="1.0", oauth_signature_method="HMAC-SHA1", oauth_consumer_key="<key>", oauth_token="<token>", oauth_signature="w%2F.nkkBk8Ic5kfvfDhM94%2F.cj4qq8%3D."\r\n\r\n'
reply: 'HTTP/1.1 401 Authorization Required\r\n'
The difference between both requests are nonce, timestamp and signature. But that looks natural to me.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Failure to send verification code okdude2124 0 843 Mar-22-2021, 07:40 PM
Last Post: okdude2124
  About Twitter Scraping ahmetcakar 1 807 Nov-14-2020, 01:43 AM
Last Post: Larz60+
  how to add proxy authentication selenium farhan275 10 8,451 Sep-10-2020, 10:18 PM
Last Post: farhan275
  Webscrapping of Images that requires Authentication junos4350 1 1,021 Jun-08-2020, 08:32 AM
Last Post: alekson
  Unable to get the data from web API using authentication key lokamaba 0 1,004 May-15-2020, 05:07 AM
Last Post: lokamaba
  Failure in web scraping by Beautiful Soup yeungcase 4 5,044 Mar-23-2019, 12:36 PM
Last Post: metulburr
  Trying to automate tweets without Twitter API HowardHarkness 10 3,932 Jan-07-2019, 01:34 AM
Last Post: HowardHarkness
  Requests login failure test 10 6,247 Sep-13-2018, 08:48 AM
Last Post: test
  authentication and os.environ questions jdischler 0 2,528 May-04-2017, 04:25 PM
Last Post: jdischler

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020