Reputation: 1897
I follow this guide from google, to set up push notification service for android(GCM). But it is actually a bit wrong, because there is no Register app button, I think it was replaced with credentials in slide bar, then I press create new key button, chose Android then find in eclipse SHA1 key (I try with console, in /home/.android/debug.keystore, there was strange thing, it asks for some password I just press enter), and I add ';com.google.android.gcm.demo.app' - my application package in manifest(it is actually working example from http://developer.android.com/google/gcm/client.html) It works nice, when I enter my SENDER ID(project number from from google cloud console).
Now I am going to write backend for this:
How should I fix this issue?
Note: I suppose I generate key wrong way because of this mismatch in guide.
Upvotes: 1
Views: 8637
Reputation: 3798
APIs & auth -> Credentials -> Create New Key -> Server Key -> Create(don't input IP)
Use Api Key in "Key for server applications"
Upvotes: 2
Reputation: 1897
I find solution I should open credentials in slide bar -> create new key - SERVER(instead of Android) then don't write any IP, it is enough for development purpose. Then this api key will be valid from server.
api_key=YOUR_API_KEY
curl --header "Authorization: key=$api_key" --header Content-Type:"application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"ABC\"]}"
response:
{"multicast_id":6782339717028231855,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}
Then just enter valid registration ID, as written here: http://developer.android.com/google/gcm/http.html#auth_error
It would be nice to change android guide here: http://developer.android.com/google/gcm/gs.html becouse it is not up to date.
Upvotes: 4