Twitter authentification OAuth en javascript

J'ai cherché partout un bon exemple d'un appel ajax JQuery pour authentifier une utilisation de Twitter à l'aide de leur méthode d'authentification OAuth. J'ai lu les instructions à plusieurs reprises et c'est ce que j'ai à ce jour, pour le moment je suis seulement en essayant d'obtenir le Oauth_Token à envoyer à l'utilisateur de valider. Je reçois l'erreur 401 non autorisé d'erreur. J'ai essayé quelques combinaisons de changer le type de données et quelques autres choses dans l'appel ajax, mais sans succès. Je crois que la "Création de la base de signature et de Créer une signature de cryptage SHA1" est correct, mais je peux me tromper. Si quelqu'un a mettre en œuvre twitter OAuth en javascript avec succès, s'il vous plaît laissez-moi savoir comment. Je ne suis pas aussi intéressés à l'utilisation d'un tiers de l'API, en fait, je veux l'apprendre. Merci d'avance pour toute aide.

Twitter instructions http://dev.twitter.com/pages/auth

Mon code (Javascript)

    //Unix time
var foo = new Date; //Generic JS date object
var unixtime_ms = foo.getTime(); //Returns milliseconds since the epoch
var unixtime = parseInt(unixtime_ms / 1000);
var callBackURL = "oob"; //oob for now
var nonce = "12342897";
//Create Signature Base String using formula
var baseSign = "POST" + "&" + encodeURIComponent("https://api.twitter.com/oauth/request_token").toString() + "&"
+ encodeURIComponent("oauth_callback") + "%3D" + encodeURIComponent(callBackURL)
+ "%26"
+ encodeURIComponent("oauth_consumer_key") + "%3D" + encodeURIComponent("*****consumer key**********")
+ "%26"
+ encodeURIComponent("oauth_nonce") + "%3D" + encodeURIComponent(nonce)
+ "%26"
+ encodeURIComponent("oauth_signature_method") + "%3D" + encodeURIComponent("HMAC-SHA1")
+ "%26"
+ encodeURIComponent("oauth_timestamp") + "%3D" + encodeURIComponent(unixtime)
+ "%26"
+ encodeURIComponent("oauth_version") + "%3D" + encodeURIComponent("1.0");
//Create Signature, With consumer Secret key we sign the signature base string
var signature = b64_hmac_sha1("********secrete key****************", baseSign);
//Build headers from signature
var jsonData = JSON.stringify({
Authorization: {
oauth_nonce: nonce,
oauth_callback: encodeURIComponent(callBackURL),
oauth_signature_method: "HMAC-SHA1",
oauth_timestamp: unixtime,
oauth_consumer_key: "**********consumer key*********",
oauth_signature: signature,
oauth_version: "1.0"
}
});
//Request Access Token
$.ajax({
url: "http://api.twitter.com/oauth/request_token",
type: "post",
headers: jsonData,
dataType: "jsonp",
success: function (data) {
alert(data);
},
error: function (data) {
alert("Error");
}

Voici la réponse HTTP

HTTP/1.1 401 Unauthorized
Date: Thu, 14 Jul 2011 21:05:55 GMT
Server: hi
Status: 401 Unauthorized
X-Transaction: 1310677555-60750-49846
X-Frame-Options: SAMEORIGIN
Last-Modified: Thu, 14 Jul 2011 21:05:55 GMT
X-Runtime: 0.01152
Content-Type: text/html; charset=utf-8
Pragma: no-cache
X-Revision: DEV
Expires: Tue, 31 Mar 1981 05:00:00 GMT
X-MID: ffc990286a86b688f1e72ef733365926ea30ca62
Vary: Accept-Encoding
Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0, proxy-revalidate
Content-Length: 44
Proxy-Connection: Keep-Alive
Connection: Keep-Alive
Set-Cookie: lang=en; path=/
Set-Cookie: lang=en; path=/
Set-Cookie: _twitter_sess=BAh7DjoOcmV0dXJuX3RvIiJodHRwOi8vdHdpdHRlci5jb20vcGF1bF9pcmlz%250AaDoJdXNlcmkEl6phBDoVaW5fbmV3X3VzZXJfZmxvdzA6D2NyZWF0ZWRfYXRs%250AKwgE9BTnMAE6B2lkIiU2MzBkYmJmNmY4YmRmY2E3NGI2NDRmZTFhNjZiNmU2%250ANToTc2hvd19oZWxwX2xpbmswOgxjc3JmX2lkIiUyODIzYWNlNmFjMzQ3OTk5%250AZDE5YmVlYmJlYzM4MTg0ZSIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6%250ARmxhc2g6OkZsYXNoSGFzaHsABjoKQHVzZWR7ADoTcGFzc3dvcmRfdG9rZW4i%250ALThkY2NlMmE1OTI5OWJmM2VjNDI4YWRiOTE0YTRmYzVjYzQwN2FkMmM%253D--22a361f562df3aa6991b81fff6f486086ab71f0e; 
domain=.twitter.com; 
path=/; HttpOnly
Proxy-support: Session-based-authentication
Age: 0
Failed to validate oauth signature and token
Avez-vous jamais trouver une solution? Je vais avoir le même problème à l'heure actuelle, il serait bien si c'était possible.

OriginalL'auteur Deylo.Woo | 2011-07-14