0

I am trying to get a simple PhoneGap application going on Android device. So, I've followed all the steps, created a project and the app successfully communicates with GCM servers and obtains registration ids using my project number.

The problem is that I can not communicate with GCM from the server side. I was originally doing this from Perl, but even curl example from GCM documentation returns "401".

They API access key is whitelisted, I've tried to delete it and create new one a few times. Tried even to use a browser key instead of server key. The same result: Unauthorized access.

And all the keys created from main (old version, not new Google Cloud) API console, as per current documentation. I could not find how to generate simple API access keys in Google Cloud Console.

As I've mentioned above, the GCM service is enabled for this project because clients can connect and obtain registration ids.

Any help where else to look at?

user2889454
  • 1
  • 1
  • 2

1 Answers1

2

Try using a "Server key" instead of "Android key", I had encountered "Unauthorized access" when using the latter one.

One you had applied a "Server key", you can verify it on the console on your Linux or Mac OS by (Please fill in the data in each line):

api_key="xx...xxx"
reg_id="yy...yy"
curl --header "Authorization: key=$api_key" --header Content-Type:"application/json" https://android.googleapis.com/gcm/send  -d "{\"registration_ids\":[\"$reg_id\"],\"data\":{\"code\":123}}"
Alan Zhiliang Feng
  • 1,774
  • 18
  • 20
  • Here is a detailed guide for that: https://github.com/PushAppsService/PushAppsSDK/tree/master/Android/Guides – Orr Dec 11 '13 at 11:25
  • 1
    Google have recently updated their console interface! You need to generate an api key for your server communicate with GCM AND a different api key for your android app to communicate with your server + GCM. See this image for a better understanding http://imgur.com/5Ge1DWk – Garbit Jan 27 '14 at 10:32