Skip to content
Browse files

Bigger nonces and stricter oauth compliance, trying to workaround twi…

…tter auth bugs
  • Loading branch information...
1 parent 6b415f6 commit 87f91799d4591379964cdf6f9e854f0c909c6ac1 @cezarsa committed Jun 27, 2012
Showing with 14 additions and 12 deletions.
  1. +3 −3 lib/3rdparty/oauth.js
  2. +11 −9 lib/twitter_lib.js
View
6 lib/3rdparty/oauth.js
@@ -260,14 +260,14 @@ OAuth.setProperties(OAuth, // utility functions
OAuth.setParameter(message, "oauth_timestamp", OAuth.timestamp());
}
if (map.oauth_nonce == null) {
- OAuth.setParameter(message, "oauth_nonce", OAuth.nonce(6));
+ OAuth.setParameter(message, "oauth_nonce", OAuth.nonce(32));
}
OAuth.SignatureMethod.sign(message, accessor);
}
,
setTimestampAndNonce: function setTimestampAndNonce(message) {
OAuth.setParameter(message, "oauth_timestamp", OAuth.timestamp());
- OAuth.setParameter(message, "oauth_nonce", OAuth.nonce(6));
+ OAuth.setParameter(message, "oauth_nonce", OAuth.nonce(32));
}
,
addToURL: function addToURL(url, parameters) {
@@ -337,7 +337,7 @@ OAuth.setProperties(OAuth, // utility functions
}
});
-OAuth.nonce.CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
+OAuth.nonce.CHARS = "0123456789abcdef";
/** Define a constructor function,
without causing trouble to anyone who was using it as a namespace.
View
20 lib/twitter_lib.js
@@ -51,13 +51,15 @@ TwitterLib.prototype = {
if(includeRealm) {
authorization += 'realm="http://api.twitter.com/", ';
}
- authorization += 'oauth_consumer_key="' + signedData.oauth_consumer_key + '", ' +
- 'oauth_signature_method="HMAC-SHA1", ' +
- 'oauth_token="' + signedData.oauth_token + '", ' +
- 'oauth_timestamp="' + signedData.oauth_timestamp + '", ' +
- 'oauth_nonce="' + encodeURIComponent(signedData.oauth_nonce) + '", ' +
- 'oauth_version="1.0", ' +
- 'oauth_signature="' + encodeURIComponent(signedData.oauth_signature) + '"';
+
+ authorization +=
+ 'oauth_consumer_key="' + signedData.oauth_consumer_key + '", ' +
+ 'oauth_nonce="' + encodeURIComponent(signedData.oauth_nonce) + '", ' +
+ 'oauth_signature="' + encodeURIComponent(signedData.oauth_signature) + '", ' +
+ 'oauth_signature_method="HMAC-SHA1", ' +
+ 'oauth_timestamp="' + signedData.oauth_timestamp + '", ' +
+ 'oauth_token="' + signedData.oauth_token + '", ' +
+ 'oauth_version="1.0"';
return authorization;
},
@@ -139,10 +141,10 @@ TwitterLib.prototype = {
fmtError = '"' + txt.replace(/<.*>(.*)<.*>/, '$1') + '"';
} else {
var rspObj = JSON.parse(request.responseText);
- fmtError = '"' + rspObj.error + '"(' + request.statusText + ')';
+ fmtError = url + ': "' + rspObj.error + '"(' + request.statusText + ')';
}
} catch(e) {
- fmtError = '"' + (error || request.statusText) + '"(' + status + ')';
+ fmtError = url + ': "' + (error || request.statusText) + '"(' + status + ')';
}
}
callback(false, null, fmtError, context, request);

0 comments on commit 87f9179

Please sign in to comment.
Something went wrong with that request. Please try again.