3
votes

i'm currently developping an application for twitter, using javascript and OAuth, for a qml environment. I'm stuck in "request_token" endpoint and i don't understand why. I only get "failed to validate oauth signature or token" when i send my request ! I've checked my signature generation with http://oauth.googlecode.com/svn/code/javascript/example/signature.html and http://quonos.nl/oauthTester/ and it does appear that my signature and my basestring are both right ! I've tried to send data in "authorization" http header field, and in body. Here is my basestring :

POST&https%3A%2F%2Fapi.twitter.com%2Foauth%2Frequest_token&oauth_consumer_key%3D26oauth_nonce%3DDbWO0M%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1303129797%26oauth_token%3D%26oauth_version%3D1.0

The part i've sent in header field "Authorization" is :

oauth_consumer_key=&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1303130860&oauth_nonce=UX2kEA&oauth_signature=LizFO9xkre2Kv5A43Oj%2F%2FaY9Wck%3D

If someone can help me with this issue... i've checked every step with OAuth library examples and other tools on the web.

2

2 Answers

0
votes

Definitely check out this answer to a similar issue. It may contain your solution: Twitter OAuth, Error when trying to POST direct message

0
votes

So it appears that Twitter's implementation of oauth does not need oauth_token to sign the basestring (as said in Twitter's API doc). Further more, you shouldn't write it in your basestring.

Authorization header field should be fill this way :

OAuth oauth_nonce="1Rek6K",oauth_callback="oob",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1303375383",oauth_consumer_key="<YOUR_CONSUMER_KEY",oauth_signature="fgb6sPPR2PHQD%2BinG2KvtvgOtXU%3D",oauth_version="1.0"

The mendatory oauth_callback sould be set as "oob" for desktop applications.