Ok, i've checked again and there is some stuff i did not see at first. So now i'm correctly generating my basestring : basestring: POST&http%3A%2F%2Fapi.twitter.com%2Foauth %2Frequest_token&oauth_consumer_key%3D[CONSUMER_KEY]%26oauth_nonce %3Dmr7yTy%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp %3D1302881089%26oauth_version%3D1.0
and this is the signature : signature: uC+AkOdUVj8fpiKL+GVLlM0QmAE= I guess the problem is in the signature but i can't figure where. On Apr 15, 4:28 pm, galeyte <[email protected]> wrote: > Hi again ! > > I'm trying to develop a desktop-application javascript based. > I'm actually trying to get the request_token from twitter. > I'm using OAuth js library, and after testing their examples, i'm > trying to do the same thing > ashttp://oauth.googlecode.com/svn/code/javascript/example/requestToken.... > do, because it seems to work and twitter respond with a valuable > request_token and secret. > To complete the exactly same request, i've been wiresharking my http > request and form the same strings with XMLHttpRequest in my code. > The only response i get is "401 - failed to validate oauth signature > or token", so i assume i make a mistake in basestring generation or > basstring signature. > my code : > function signForm() { > accessor = { consumerSecret: consumer_secret > , tokenSecret : oauth_token_secret}; > message = { action: "/request_token" > , method: "POST" > , parameters: []}; > message.parameters.push(["oauth_consumer_key", consumer_key]); > message.parameters.push(["oauth_signature_method", > signature_method]); > OAuth.setTimestampAndNonce(message); > OAuth.SignatureMethod.sign(message, accessor); > return true; > > } > > function getSignature() { > signForm(); > console.log(OAuth.getParameter(message.parameters, > "oauth_signature")); > OAuth.completeRequest(message, accessor); > request_maker = new XMLHttpRequest(); > request_maker.open("POST", "http://api.twitter.com/oauth/ > request_token"); > request_maker.setRequestHeader("Host", "api.twitter.com"); > request_maker.setRequestHeader("Content-type", "application/x-www- > form-urlencoded"); > request_maker.onreadystatechange = oth_func; > request_maker.send("oauth_consumer_key="+consumer_key > +"&oauth_signature_method="+signature_method > +"&oauth_timestamp="+OAuth.getParameter(message.parameters, > "oauth_timestamp") > +"&oauth_nonce="+OAuth.getParameter(message.parameters, "oauth_nonce") > +"&oauth_signature="+encodeURI(OAuth.getParameter(message.parameters, > "oauth_signature"))); > > } > > I've seen some "base64" encoding in some twitter client sources, but > since it's not mentioned in twitter api doc, i don't use base64. > > If you have any clue to help me go through this issue, i'd be > gratefull ! -- Twitter developer documentation and resources: http://dev.twitter.com/doc API updates via Twitter: http://twitter.com/twitterapi Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list Change your membership to this group: http://groups.google.com/group/twitter-development-talk
