Get the Sender Auth Token for GCM in android - android

In developer website
there is a Sender Auth Token in the credentials but how to get it?
Please tell me the steps as it is not clear to me.

as Written in Documentation like below.
Sender Auth Token :An API key that is saved on the 3rd-party application server that gives the application server authorized access to Google services. The API key is included in the header of POST requests that send messages.
you can get API KEY from you from HERE
you can get more informations here
EDITED
GCM SERVER SIDE IMPLEMENTATION IN DRUPAL

Related

My Gcmdemo project not working

I have used gcm demo code for viewing working of different features of gcm.But unfortunately it is showing some error.My client side is gcm quickstart code ,which is working finely,successfully sent notification using command code(gcm sender) .But i have few doubts-
Is it possible to send message/notification from gcm demo code to gcm quickstart?
2.I have used sender id and api key of gcm quickstart for sending notification from gcm demo.
3.Is there any correction required in gcm demo?
As GCM Reference 401 is authentication issue and possible problems are explained below;
The sender account used to send a message couldn't be authenticated.
Possible causes are:
Authorization header missing or with invalid syntax in HTTP request.
Invalid project number sent as key.
Key valid but with GCM service disabled.
Request originated from a server not whitelisted in the Server Key IPs.
Check that the token you're sending inside the Authentication header
is the correct API key associated with your project. See Checking the
validity of an API Key for details.

How does google cloud messaging verify it's the correct app server?

When sending down stream messages from the app server to GCM to the client, how does GCM verify that it is actually from the app server and not some spoof? For example, I could use a REST client and send POST requests to GCM that would still reach the registered client as long as I have the API key and user ids. Is it all about making sure the API key does not get exposed then? Are expected to do some extra verifications on the Client?
You can restrict allowed server IP addresses at Google developers console.
The API key is the main means of identifying an allowed sender. If you have the API key and the client InstanceId token (id) then you are an allowed sender, this is by design. You can revoke API keys if you believe that they have been compromised.

Google GCM, token vs registration id

I am confused on relationship between registration id and tokens. In the tutorial for GCM from Google, we register for a registration id in the beginning. However, we also get a token. Now, in the diagrams, we send the registration id to the targeted server. However, do we also send the token? I know that the token is derived from the registration id. Is the token used as an authentication mechanism between GCM and the app and the server never knows about the token?
If you are looking for a basic knowledge about Google Cloud Messaging, IMO, you can refer to the following:
Basically, you need to do the steps:
Create a new project at Google Developers Console . At this
step, for simplicity, you just need to take note of 2 values: Project Number, which
will be used as SENDER_ID in the client project; and API server key (created at Credentials), which
will be used as API_KEY in the server project.
Create a new simple Android project for server side (with basic source code as my answer in the following links).
Create a new simple Android project for client side (with basic source code as my answer in the following links, I customized from the original source at Google Cloud Messaging - GitHub).
Run the client app, you will get the registration token (means that your device has successfully registered). Then, paste (hard-code) this token at CLIENT_REGISTRATION_TOKEN variable in server app (or write code to send this token to server app).
You can read more at the following questions, one of them you have read before with one of your previous questions:
How to implement a GCM Hello World for Android using Android Studio
Adding Google Cloud Messagin (GCM) for Android - Registration process
For more information:
Key Concepts from Google Cloud Messaging: Overview
Credentials
Sender ID A unique numerical value created when you configure your API project (given as "Project Number" in the Google Developers Console). The sender ID is used in the registration process to identify an app server that is permitted to send messages to the client app.
API Key An API key saved on the app server that gives the app server authorized access to Google services. In HTTP, the API key is
included in the header of POST requests that send messages. In XMPP,
the API key is used in the SASL PLAIN authentication request as a
password to authenticate the connection. You obtain the API key when
you configure your API project.
Registration Token An ID issued by the GCM connection servers to the client app that allows it to receive messages. Note that
registration tokens must be kept secret.
Hope this helps!
GCM now uses the concept of an InstanceID which represents a single install of an app on a device (Android or iOS). Each InstanceID can issue several tokens. These tokens are used to identify the InstanceID and can expire and be refreshed.
On the client device, you initialize an InstanceID, then with that InstanceID you generate a token (registration token). You send that token to your server, which uses the token to send messages to the InstanceID (installed application). If that token is invalidated for any reason like the application is uninstalled or the token is compromised, a new token should be generated and sent to your server.
I am still successfully registering with registration Id method until 11 May 2016
if (checkPlayServices()) {
gcm = GoogleCloudMessaging.getInstance(this);
regid = getRegistrationId(context);
if (regid.isEmpty()) {
registerInBackground();
}
} else {
Log.i(TAG, "No valid Google Play Services APK found.");
}
APA91bHLUfr71D6K7VTrRH3LGiLFxGNr3qRi3xOB_yNl0fLYsqhlgYXxHzOhQx2WKgqZI3sqxa1ZPORa0-5YBZ1_OFLm9cEg1bTh7wtrpCsHW91MSs2BMIXrHEqyjj2TeoVxnAzA5U8s

Do I need to regenerate the C2DM Auth Token if the account password is changed?

I know C2DM is deprecated and code should be migrated to Google Cloud Messaging for Android (GCM). But we have an existing application using C2DM. The application was built for a client and the client provided the original C2DM authorization token.
Recently, it appears that C2DM messaging stopped for our application. Our theory is that the client changed the password on the Google account and we now need an updated authorization token.
Is this correct? If the Google account's password changes, do you need to create a new authentication token? I can't find any document or SO post that discusses this.

sending message C2DM to google server get error

I try to test c2dm app. I have sign up for Android Cloud to Device Messaging. http://code.google.com/android/c2dm/signup.html
I register from my app and sender id to c2dm service and i get registration_id.
After that my third party server must get ClientLogin authentication using email and password. But when i use the registration_id and authorization_id to send message to C2DM Server, i got response AccountDisabled. What does it means? Can you show me how to fix it? Thanks a lot.
I think it's problems with ClientLogin (in the end of page):
http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html

Categories

Resources