On my node application project, I have migrated Twitter API from v1.0 to v1.1. And I have found some errors in my log file.
Error
{"message":"Could not authenticate you","code":32}
Cause
This error occurs, if post data (to 1.1/statuses/update) is including...
- !
- '
- (
- )
- *
Solution
I have patched node_modules/oauth/lib/oauth.js of node-oauth(only used node-twitter)...
from
327 if( (method == "POST" || method == "PUT") && ( post_body == null && extra_params != null) ) {
328 post_body= querystring.stringify(extra_params);
329 }
to
327 if( (method == "POST" || method == "PUT") && ( post_body == null && extra_params != null) ) {
328 post_body= querystring.stringify(extra_params);
+331 post_body= post_body.replace(/\!/g, "%21")
+332 .replace(/\'/g, "%27")
+333 .replace(/\(/g, "%28")
+334 .replace(/\)/g, "%29")
+335 .replace(/\*/g, "%2A");
336 }
Twitter API v1.0 don't require this patch. Only v1.1 requires this patch double-escaping a post body. I think my patch is not universal, because this changing will make it impossible to use this library for any other oauth service...
My Questions
- This is node-oauth problem or Twitter API problem (Twitter Spec chage or bug)?
- Who should I report this problem to?