Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I couldn't figure out how to use C2DM with oAuth 2.0 yet but here's what I've tried. Hope this can help someone to solve similar problem</p> <p>I found a resource that would be useful at <a href="http://aleksmaus.blogspot.com/2012/01/oauth2-with-google-c2dm-push.html" rel="nofollow">http://aleksmaus.blogspot.com/2012/01/oauth2-with-google-c2dm-push.html</a> But when I tried to send message with C2DM through OAuth 2.0 it didn't work while did a good job with ClientLogin. </p> <p>This is how I did with console and web browser (I know, you've asked PHP implementation. But I hope this can also be helpful for you)</p> <hr> <h1>Client Login: (Succeeded)</h1> <p>got auth token from: </p> <pre><code>$ curl -k -d "accountType=HOSTED_OR_GOOGLE&amp;service=ac2dm&amp;source=test-1.0&amp;Email=[email account with @gmail.com without brace]&amp;Passwd=[Google account password without brace]" https://www.google.com/accounts/ClientLogin </code></pre> <p>And sent C2DM message like this:</p> <pre><code>$ curl -k --header "Authorization: GoogleLogin auth=[my ClientLogin auth key without brace]" -d "registration_id=[can be acquired from Android application]" --trace c2dm_trace.txt -d collapse_key=0 https://android.apis.google.com/c2dm/send </code></pre> <p>Then my application successfully received C2DM message</p> <hr> <h1>oAuth 2.0: (Failed)</h1> <p>got an oAuth 2.0 auth credential from web browser by accessing url:</p> <pre><code>https://accounts.google.com/o/oauth2/auth?response_type=code&amp;client_id=[can be acquired from API Access menu in your API Console]&amp;redirect_uri=urn:ietf:wg:oauth:2.0:oob&amp;scope=https%3A%2F%2Fandroid.apis.google.com%2Fc2dm&amp;access_type=offline </code></pre> <p>(Google API Console: <a href="https://code.google.com/apis/console/" rel="nofollow">https://code.google.com/apis/console/</a> )</p> <p>And sent like this:</p> <pre><code>$ curl -k -H "Authorization: Bearer [my auth key from oAuth]" --trace curl_trace.txt -d "registration_id=[an be acquired from Android application]" -d "data.message=something to talk" -d collapse_key=0 https://android.apis.google.com/c2dm/send </code></pre> <p>Then got <strong>401 error response</strong> :(</p> <hr> <p>Is there anybody who can point out what I've done something wrong?</p> <p><strong>Edit</strong></p> <p>I've found the sentence <strong>"AC2DM is currently an API in Labs"</strong> in the mail that you might received from Google when register C2DM. And <a href="https://developers.google.com/accounts/terms" rel="nofollow" title="Google Account Policy">ClientLogin deprecation policy will not apply to versions, features, and functionality labeled as "experimental."</a> I'm not sure but I think this is why our codes didn't work.</p> <p>Of course, I hope ClientLogin also be deprecated and replaced with OAuth 2.0 soon</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload