401 Unauthorized error while posting status with Unicode characters (non english characters)

42 views
Skip to first unread message

Satheesh Natesan

unread,
Sep 24, 2009, 5:16:28 PM9/24/09
to Twitter Development Talk
I am getting "401 Unauthorized" exception when updating status with
non english characters using my app.

This exception is happening for any Japanese or Korean characters.

Another interesting thing is that it is possible to post some other
non english characters like Malayalam. The exception will not happen
for single word in these cases, but occurs for multiple words.
For example consider the following example

ØáÇÞµæù çµdw - does not work

ØáÇÞµæùçµdw - with space removed works.

Base signature for "ØáÇÞµæù çµdw" which throws exception is

POST&http%3A%2F%2Ftwitter.com%2Fstatuses
%2Fupdate.json&oauth_consumer_key%
3DwmeO7Y20oMFa1ptKVY4WA%26oauth_nonce
%3D4504682%26oauth_signature_method%
3DHMAC-SHA1%26oauth_timestamp%3D1253727596%26oauth_token%3D76084396-
0M9ll2nghrjWhjALbH7YEHXizcLDNvoLfgXKfHQZQ%26oauth_version
%3D1.0%26status%
3D%25D8%25E1%25C7%25DE%25B5%25E6%25F9%2520%25E7%25B5dw

and for "ØáÇÞµæùçµdw" which works is

POST&http%3A%2F%2Ftwitter.com%2Fstatuses
%2Fupdate.json&oauth_consumer_key%
3DwmeO7Y20oMFa1ptKVY4WA%26oauth_nonce
%3D9388868%26oauth_signature_method%
3DHMAC-SHA1%26oauth_timestamp%3D1253727793%26oauth_token%3D76084396-
0M9ll2nghrjWhjALbH7YEHXizcLDNvoLfgXKfHQZQ%26oauth_version
%3D1.0%26status%
3D%25D8%25E1%25C7%25DE%25B5%25E6%25F9%25E7%25B5dw


OAuth client library I am using is in .Net

Could you please help to solve this issue? Also I would like to know
you support all unicode characters.
Your help is greatly appreciated.

Thanks,
Satheesh Natesan

Carlos

unread,
Sep 24, 2009, 9:49:21 PM9/24/09
to Twitter Development Talk
Are you sure you are encoding your posts as UTF-8?

On Sep 24, 5:16 pm, Satheesh Natesan <satheesh.nate...@gmail.com>
wrote:

Satheesh Natesan

unread,
Sep 25, 2009, 5:00:21 PM9/25/09
to twitter-deve...@googlegroups.com
Yes, it is UTF-8 encoded.
 
The request body for "の脚本家が贈る" is
oauth_consumer_key=wmeO7Y20oMFa1ptKVY4WA&oauth_nonce=3231757&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1253903495&oauth_token=76084396-0M9ll2nghrjWhjALbH7YEHXizcLDNvoLfgXKfHQZQ&oauth_version=1.0&status=%306E%811A%672C%5BB6%304C%8D08%308B&oauth_signature=AMcLsF43vPP6Hmn8fv%2bZCMdqEnU%3d
 
and the base signature is
POST&http%3A%2F%2Ftwitter.com%2Fstatuses%2Fupdate.json&oauth_consumer_key%3DwmeO7Y20oMFa1ptKVY4WA%26oauth_nonce%3D3231757%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1253903495%26oauth_token%3D76084396-0M9ll2nghrjWhjALbH7YEHXizcLDNvoLfgXKfHQZQ%26oauth_version%3D1.0%26status%3D%25306E%25811A%25672C%255BB6%25304C%258D08%25308B
 
Do you see anything wrong here?
 
Thanks!
Satheesh Natesan

Mageuzi

unread,
Sep 25, 2009, 10:54:47 PM9/25/09
to Twitter Development Talk
Hello,
I had this same problem. I had to convert all multi-byte characters
into their individual bytes.
So, for example, for the character "の":
Your example has %306E, but the encoding that works for me is
%E3%81%AE (three bytes for the three-byte character).


On Sep 25, 5:00 pm, Satheesh Natesan <satheesh.nate...@gmail.com>
wrote:
> Yes, it is UTF-8 encoded.
>
> The request body for "の脚本家が贈る" is
> oauth_consumer_key=wmeO7Y20oMFa1ptKVY4WA&oauth_nonce=3231757&oauth_signatur­e_method=HMAC-SHA1&oauth_timestamp=1253903495&oauth_token=76084396-0M9ll2ng­hrjWhjALbH7YEHXizcLDNvoLfgXKfHQZQ&oauth_version=1.0&status=%306E%811A%672C%­5BB6%304C%8D08%308B&oauth_signature=AMcLsF43vPP6Hmn8fv%2bZCMdqEnU%3d
>
> and the base signature is
> POST&http%3A%2F%2Ftwitter.com%2Fstatuses%2Fupdate.json&oauth_consumer_key%3­DwmeO7Y20oMFa1ptKVY4WA%26oauth_nonce%3D3231757%26oauth_signature_method%3DH­MAC-SHA1%26oauth_timestamp%3D1253903495%26oauth_token%3D76084396-0M9ll2nghr­jWhjALbH7YEHXizcLDNvoLfgXKfHQZQ%26oauth_version%3D1.0%26status%3D%25306E%25­811A%25672C%255BB6%25304C%258D08%25308B
> > > Satheesh Natesan- Hide quoted text -
>
> - Show quoted text -

JDG

unread,
Sep 26, 2009, 11:11:02 AM9/26/09
to twitter-deve...@googlegroups.com
That's true -- %5BB6, for example, is NOT a UTF-8 encoded codepoint for a character. It's Unicode (or UTF-16).
--
Internets. Serious business.

Satheesh Natesan

unread,
Sep 28, 2009, 1:59:03 PM9/28/09
to twitter-deve...@googlegroups.com
Thanks, I will try that!
Reply all
Reply to author
Forward
0 new messages