ajgoune / python-twitter

Automatically exported from code.google.com/p/python-twitter
Apache License 2.0
0 stars 0 forks source link

Invalid Signature #157

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
>>> import twitter
>>> api = twitter.Api(username='XXXXXXX', password='YYYYYYYYY', 
access_token_key='ZZZZZZZ', access_token_secret='TTTTTT')
>>> txt = "Oauth test"
>>> status = api.PostUpdate(txt)
send: 'POST /1/statuses/update.json HTTP/1.1\r\nAccept-Encoding: identity\r\nCon
tent-Length: 268\r\nHost: api.twitter.com\r\nContent-Type: application/x-www-for
m-urlencoded\r\nConnection: close\r\nUser-Agent: Python-urllib/2.7\r\n\r\nstatus
=Oauth+test&oauth_version=1.0&oauth_token=TTTTTTTTTT&oauth_nonce=43344504&oauth_
timestamp=1283580238&oauth_signature=YYYYYYYYY%3D&oauth_consumer_key=XXXXXXXXX&o
auth_sign
ature_method=HMAC-SHA1'
reply: 'HTTP/1.1 401 Unauthorized\r\n'
header: Date: Sat, 04 Sep 2010 06:04:01 GMT
header: Server: hi
header: Status: 401 Unauthorized
header: WWW-Authenticate: Basic realm="Twitter API"
header: Content-Type: application/json; charset=utf-8
header: Content-Length: 67
header: Cache-Control: no-cache, max-age=300
header: Set-Cookie: k=78.177.5.60.1283580241948500; path=/; expires=Sat, 11-Sep-
10 06:04:01 GMT; domain=.twitter.com
header: Set-Cookie: guest_id=128358024195473774; path=/; expires=Mon, 04 Oct 201
0 06:04:01 GMT
header: Set-Cookie: _twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCDIoWNsqAToHaWQiJWU1Nz
ZkOWMyNWE1ODg1%250AMTYyMjg3ZDdmM2MzMTNjMjhiIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%
250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--98d82529dddd101a41ac112bb888d6f7b0
c112ba; domain=.twitter.com; path=/
header: Expires: Sat, 04 Sep 2010 06:09:01 GMT
header: Vary: Accept-Encoding
header: Connection: close
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build\bdist.win32\egg\twitter.py", line 2158, in PostUpdate

  File "build\bdist.win32\egg\twitter.py", line 2943, in _CheckForTwitterError

twitter.TwitterError: Incorrect signature
>>>

What is the expected output? What do you see instead?
I would like to post a message but I get invalid signature error.

What version of the product are you using? On what operating system?
0.6-devel

Please provide any additional information below.

Original issue reported on code.google.com by mert.sar...@gmail.com on 4 Sep 2010 at 6:09

GoogleCodeExporter commented 8 years ago
It is 0.8-devel not 0.6-devel, I'd like to correct it.

Original comment by mert.sar...@gmail.com on 4 Sep 2010 at 6:36

GoogleCodeExporter commented 8 years ago
hi, could you fix this error? I have the same problem.

Original comment by jjvainst...@gmail.com on 5 Sep 2010 at 1:10

GoogleCodeExporter commented 8 years ago
Go with oauthtwitter until author fixes it.

Original comment by mert.sar...@gmail.com on 5 Sep 2010 at 1:24

GoogleCodeExporter commented 8 years ago
I'm having similar problems. Results are mixed. I get no error with 
GetFollowers(), GetFriends(), GetUserTimeline(), GetFavorites()

I get Incorrect Signature with:
GetReplies()
VerifyCredentials()

I haven't tried to do exhaustive testing.

Original comment by joegermu...@gmail.com on 5 Sep 2010 at 2:56

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Try a single word tweet (ie no spaces). If that works you might want to try 
using a different oath library. I'm having good luck with the one from: 
http://github.com/simplegeo/python-oauth2

Original comment by c...@codeware.com on 6 Sep 2010 at 4:06

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
> Comment #7 on issue 157 by lcostantino: Invalid 
Signaturehttp://code.google.com/p/python-twitter/issues/detail?id=157
> 
> A fast test, revealed that  replacing on oauth2/__init__.py
> 
> def to_postdata(self):
>      return urllib.urlencode(self,True).replace('+','%20')
> to
> def to_postdata(self):
>      return urllib.urlencode(self,False)

I did this change, but still it's not working:

Creating message for @ocelma ...

modified to_postdata <-- This print shows that I'm using the modified version 
of oauth2 (in to_postdata method)

POST DATA:

send: 'POST /1/statuses/update.json HTTP/1.1\r\nAccept-Encoding: 
identity\r\nContent-Length: 337\r\nHost: api.twitter.com\r\nContent-Type: 
application/x-www-form-urlencoded\r\nConnection: close\r\nUser-Agent: 
Python-urllib/2.6\r\n\r\n'
send: 
'status=%40ocelma+here%27s+a+playlist+based+on+Desafinado+by+Stan+Getz+http%3A%2
F%2Fbit.ly%2F9nHnQ4&oauth_version=1.0&oauth_token=144289091-YjJho4FOXgIUnx9Q1As4
w3cFJNTuSNDyCBvjNocW&oauth_nonce=46412517&oauth_timestamp=1283879117&oauth_signa
ture=hptpsGAI3KehNybKgMhj1WzEVFk%3D&oauth_consumer_key=groovify&oauth_signature_
method=HMAC-SHA1'
reply: 'HTTP/1.1 401 Unauthorized\r\n'
header: Date: Tue, 07 Sep 2010 17:05:17 GMT
header: Server: hi
header: Status: 401 Unauthorized
header: WWW-Authenticate: Basic realm="Twitter API"
header: Content-Type: application/json; charset=utf-8
header: Content-Length: 67
header: Cache-Control: no-cache, max-age=300
header: Set-Cookie: k=187.145.13.59.1283879117754144; path=/; expires=Tue, 
14-Sep-10 17:05:17 GMT; domain=.twitter.com
header: Set-Cookie: guest_id=128387911786370398; path=/; expires=Thu, 07 Oct 
2010 17:05:17 GMT
header: Set-Cookie: 
_twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCC%252BkKO0qAToHaWQiJTI3NWU5ZTUyNTNmNmQ4%2
50ANTI5ZjdkMDZmMDkwYzBiNWVjIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6
Rmxhc2hIYXNoewAGOgpAdXNlZHsA--fd40458536dad8d41f1b419f4aeb9a187018f7dc; 
domain=.twitter.com; path=/
header: Expires: Tue, 07 Sep 2010 17:10:17 GMT
header: Vary: Accept-Encoding
header: Connection: close
Incorrect signature
=================

> Seems to work ok on PostUpdate, registration, etc.

Not to me... :-(

Original comment by oce...@gmail.com on 7 Sep 2010 at 5:10

GoogleCodeExporter commented 8 years ago
:(, i think that i just changed the urlencode(self,False) and also i am sending 
pure ascii to PostUpdate. If using Qt for example,  PostUpdate( 
str(QString().toAscii().data())

May you check if sending non unicode to PostUpdate, works for you? Of course, 
just for testing purposes.
Regards

Original comment by lcostant...@gmail.com on 9 Sep 2010 at 2:52

GoogleCodeExporter commented 8 years ago
> May you check if sending non unicode to PostUpdate, works for you? 
> Of course, just for testing purposes.

No, it doesn't work either.

Original comment by oce...@gmail.com on 9 Sep 2010 at 9:35

GoogleCodeExporter commented 8 years ago
Can you try this again but check that the python-oauth2 library is the one from 
the simplegeo fork.  I discovered that I did not update the README with the 
link to the proper library.

Please re-open if you continue to have this issue

Original comment by bear42 on 16 Oct 2010 at 7:46

GoogleCodeExporter commented 8 years ago
Sure, I'm using simplegeo ( simplegeo-python-oauth2-1.2.1-0-g1f9640f.tar.gz ).
Still, I get the same error:

twitter.TwitterError: Incorrect signature

[ BTW, how can I re-open this ticket? Thx! ]

Original comment by oce...@gmail.com on 29 Oct 2010 at 5:23