Skip to main content

c2dm 401 error when sending messages after receiving id and auth token


I have seen many similiar questions but no good answer despite some of them being accepted. I have registered for C2DM. I received confirmation email. Then I wrote some simple app to register for C2DM. I get the id (tried on emulator and on real device). Then I got the auth token (with curl) for my email that I used for C2DM registration (the same email that I use in app for acquiring the id).





When I try to do the push (also with curl), I get 401 error (like the auth token is wrong).



I read many tutorials and I am running out of ideas.


Source: Tips4allCCNA FINAL EXAM

Comments

  1. Let me try it (with curl only):

    At first we are applying for the auth token:

    curl.exe -v -k https://www.google.com/accounts/ClientLogin -d Email=xyz@gmail.com -d Passwd=secret -d accountType=GOOGLE -d source=your.registered.domain -d service=ac2dm

    In the result your are receiving the auth token:

    < HTTP/1.1 200 OK
    SID=XXX
    LSID=XXX
    Auth=XXX
    * Connection #0 to host www.google.com left intact
    * Closing connection #0
    * SSLv3, TLS alert, Client hello (1):

    Please note that the Auth response is in the result with an uppercase first letter: "Auth=XXX"!

    Now we are using the result for the next request but with lowercase first letter:
    curl.exe -v -k --header "Authorization: GoogleLogin auth=XXX" https://android.apis.google.com/c2dm/send -d "registration_id=XXX" -d "data=helloooo" -d collapse_key=Z

    And this works! But you are getting a 401 error, if you are using the auth like in the first response (upper case A in "Auth"):

    curl.exe" -v -k --header "Authorization: GoogleLogin Auth=XXX" https://android.apis.google.com/c2dm/send -d "registration_id=XXX" -d "data=helloooo" -d collapse_key=Z

    So the "auth" of request 2 is case sensitive. I think this is a pitfall 50% of the users are stepping into. Hope that helps.

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.