Skip to content

Silly problem: 401 - Code 32 with some characters in POST /statuses/update#26

Closed
martin-naumann wants to merge 2 commits into
ttezel:masterfrom
martin-naumann:master
Closed

Silly problem: 401 - Code 32 with some characters in POST /statuses/update#26
martin-naumann wants to merge 2 commits into
ttezel:masterfrom
martin-naumann:master

Conversation

@martin-naumann

Copy link
Copy Markdown

I encountered a weird bug.
When you have some special characters (e.g. "!") in your params to post a new tweet, it fails with Status 401, Code 32.
This error only appears in API v. 1.1 - 1.0 is fine.
The discussion at https://dev.twitter.com/discussions/11280 gave me the hint to try sending the POST data in the querystring instead of the body (wtf?) and 🎯 it worked!
As it doesn't seem to harm and solves this little pitfall, I patched the oarequest to supply POST params in the querystring, like GET did.
I don't know if this is a good idea or not - if you can think of a better way, I'd be glad to go it!

@kai-koch

Copy link
Copy Markdown

In your patch you simply use get instead of post. This will work for posting a new tweet, but not for the Stream API

It will work if you got only a few keywords to track.
BUT the length of GET is restricted (4092 or 8192 chars?).
So if your search exceeds the GET-limit you either receive an error because the search is truncated somewhere in the middle or later query terms aren't searched at all.

Did you test your patch with really long queries on the public stream end-point?

@martin-naumann

Copy link
Copy Markdown
Author

Shit! You're right.
That brings me back to the root cause I suspect to be responsible for this problem: Some chars (e.g. "!" are not escaped properly. Any idea on this?

@kai-koch

Copy link
Copy Markdown

It's a problem with the Oauth-module:
check "Fix requests containing !'()* in POST data": ciaranj/node-oauth#114

so when you update the Oauth-module in your installation the issue should be fixed.

@kai-koch

Copy link
Copy Markdown

NPM is not up to date yet.
There is no version bump for oauth, yet, but the fix is already merged on github.

So you have to apply the patch manually to your installation of oauth. (Normally in twit/node_modules/oauth/lib/oauth.js)

Please test and tell us if it worked. :-)

@ttezel

ttezel commented Nov 30, 2012

Copy link
Copy Markdown
Owner

@kai-koch is right. I fixed this in twit by checking in the oauth module and published a new version of twit (v1.0.11). This version works with characters requiring escaping. Thanks for letting me know about that serious issue!

@ttezel ttezel closed this Nov 30, 2012
@martin-naumann

Copy link
Copy Markdown
Author

Ah, I get it. Thanks for pointing it out to me! I already wondered where this weird problem comes from and why nobody pointed it out before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants