4
votes

I want to Use Trial version of Urban Airship for Push notification.
On registering application page of Urban Airship it require Google C2DM Authorization Token. but i am not able to get the C2DM Authorization Token from Google. i have registered my email ID with google to start using C2DM but they did not provide me any Authorization Token..

how can i get C2DM Authorization Token from Google?

3
Thanks @OllieC but i accept as answer when it is working for me because other people searching for the same problem focus mainly on accepted answer. so i cannot accept answer which is not correct. thanks btw - waseemwk

3 Answers

4
votes

Visit this site give your details and get your C2DM authorization token HURL

0
votes

You have to wait around 24 hours to get authorized for C2DM, sometimes more. But you will receive an email for confirmation when you can get your token using curl as explained in the docs.

0
votes

You need to use the Google ClientLogin HTTP API to request an auth token, using your C2DM account email and password:

public static String getClientLoginAuthToken() {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost("https://www.google.com/accounts/ClientLogin");
try {
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
    nameValuePairs.add(new BasicNameValuePair("Email", "C2DMEMAILADDRESS));
    nameValuePairs.add(new BasicNameValuePair("Passwd", "C2DMPASSWORD));
    nameValuePairs.add(new BasicNameValuePair("accountType", "GOOGLE"));
    nameValuePairs.add(new BasicNameValuePair("source", "Google-cURL-Example"));
    nameValuePairs.add(new BasicNameValuePair("service", "ac2dm"));
    post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
    HttpResponse response = client.execute(post);
    BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
    String line = "";
    while ((line = rd.readLine()) != null) {
        Trace.e("HttpResponse", line);
        if (line.startsWith("Auth=")) {
            return line.substring(5);
        }
    }
} catch (IOException e) {
    e.printStackTrace();
}
Trace.e(TAG, "Failed to get C2DM auth code");
return "";
}

For more information on the auth token, see this tutorial: http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html