How to get a C2DM authorization token for using a city airship

I want to use a trial version of Urban Airship for push notifications .
The Urban Airship page registration page requires a Google C2DM Account . but I cannot get the C2DM authorization token from Google. I registered my email id with Google to start using C2DM, but they did not provide me with any authorization token.

How can I get the C2DM authorization token from Google?

+4
source share
3 answers

Visit this site, provide your details and receive a C2DM HURL authorization token

+4
source

You need to wait about 24 hours to get permission for C2DM, and sometimes more. But you will receive an confirmation email when you can receive your token using curl, as described in the docs.

0
source

You need to use the Google ClientLogin HTTP API to request an authentication token using the C2DM account email address 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 about auth token, see this tutorial: http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html

0
source

Source: https://habr.com/ru/post/1401560/


All Articles