Unauthorized 401 when sending message

158 views
Skip to first unread message

Thomas Dybdahl Ahle

unread,
Mar 25, 2011, 4:58:09 AM3/25/11
to androi...@googlegroups.com
Hi, I have a problem using c2dm.
I have registered a Google account and can get auth tokens for c2dm, but when I try to send messages I get an html error 401 back.
I'm quite sure I'm doing everything the right way. Any ideas of what might be wrong?

curl https://www.google.com/accounts/ClientLogin -d Email=a...d@x...n.dk -d Passwd=j3n219qq -d accountType=HOSTED_OR_GOOGLE -d source=Google-cURL-Example -d service=ac2dm

SID=DQAAAIUAAACcLjGqSz0a9tqnChFiYsKVSOKFpKQDr0UrnPcvTfGs-EebLG8EKowaJaz2n-5YrB4yQt6s2RsJKcKDwUKIQ_f2x6kS4dx-qrzOvHnMWLyXbXzYl1OEZ6A4b4KKyI5SygDG7z7n-FhpDszEU8boVBJuvtG5mFJ6jLapLmg0Xk3OTtraJoLHFvww4gnEv-0Aauw
LSID=DQAAAIYAAABHE7jizFw7VLW4EoQ7YIaBcIDJRdAhwGMqR0DtTSfJJpFo7kaqUKY2RS22VfQuSZoFklOLNXUAfR2Ts_8t3To4WJqJWOOoQppf6Td5Y7o2QE4Irj7dvev0O17rYd5ynx8f063KqHzLhK5LH-5PtBPpgfvZwOnyZJkx3xV0bYoonhiDP9tAs_2HojyeqrYJWik
Auth=DQAAAIgAAAAvRHm60ugHcdtsWk---qOCaPvTSasIfadz84-NY_oa7amuE1fYxzHOUT5KrL4_tuKm81ZFP3y_Gb-M6jkk8Mnu2nRLkSQI6lOw-CzteeFTJYV3LIov_oLdPuqucAN63fUq0Iv2GCnfc7Di8Kz0Vd6NwDzmIK20_rwLUSWlPj2nDLVc4vt5W_aesyYMcWu5MsQ

curl --header "Authorization: GoogleLogin auth=DQAAAIgAAAAvRHm60ugHcdtsWk---qOCaPvTSasIfadz84-NY_oa7amuE1fYxzHOUT5KrL4_tuKm81ZFP3y_Gb-M6jkk8Mnu2nRLkSQI6lOw-CzteeFTJYV3LIov_oLdPuqucAN63fUq0Iv2GCnfc7Di8Kz0Vd6NwDzmIK20_rwLUSWlPj2nDLVc4vt5W_aesyYMcWu5MsQ" "https://android.apis.google.com/c2dm/send" -d registration_id=APA91belVJcajswYNwZLvxn9w1y6OCkg46aDpmsnOBmY8oKRZWS2CYgVXnxEHX8z7FcslClzb -d "data.message=StringToPass" -d collapse_key=something -k

<HTML>
<HEAD>
<TITLE>Unauthorized</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unauthorized</H1>
<H2>Error 401</H2>
</BODY>
</HTML>

Rick Alther

unread,
Mar 26, 2011, 8:39:13 AM3/26/11
to androi...@googlegroups.com
Looks good to me.  The only thing I can think of is make sure that there aren't any carriage returns/line breaks in the auth token.  Capture the actual request that is going to Google - that will help clarify what's going on.

- Rick

Nasif Noorudeen

unread,
Mar 27, 2011, 10:18:31 AM3/27/11
to androi...@googlegroups.com
strip any whitespace and \n

andrew

unread,
Mar 28, 2011, 12:22:23 AM3/28/11
to android-c2dm
I had similar issue.. I think using a gmail account fixed it.

Thomas Dybdahl Ahle

unread,
Apr 12, 2011, 9:33:32 AM4/12/11
to androi...@googlegroups.com
Good idea, this helped solve the problem.

Thomas Dybdahl Ahle

unread,
Apr 12, 2011, 9:34:48 AM4/12/11
to androi...@googlegroups.com
Yes, for me as well.
I mistakenly wrote "GoogleLogin Auth" instead of "GoogleLogin auth" when testing with the gmail account, and got the same html error.
But now it seams to work. Thanks alot.
Reply all
Reply to author
Forward
0 new messages