yoghesh / gcm

Automatically exported from code.google.com/p/gcm
Apache License 2.0
0 stars 0 forks source link

"Generate a Notification Key on the Client" results in HTTP 401 Unauthorized response #52

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Follow the instructions: 
https://developer.android.com/google/gcm/notifications.html#gen-client

What is the expected output? What do you see instead?
Expect HTTP 200 response with notification_key value.
Instead get HTTP 401 Unauthorized response with an HTML body stating the same.

What version of the product are you using? On what operating system?
Google Play Services 6.5.87, Android 5.0.1.

Please provide any additional information below.
POSTing to https://android.googleapis.com/gcm/googlenotification.
Including header Content-Type: application/json; charset=UTF-8.
Including project_id header with project number from Google Developers Console.
Body contains:
- "operation":"add"
- a unique notification_key_name
- a single value for registration_ids that I just received from 
GoogleCloudMessaging.register and can use to successfully send messages from 
the server to the device
- valid id_token (I can verify it and get the payload on the server)

Can you specify in which cases the service will respond with HTTP 401 
Unauthorized?

Original issue reported on code.google.com by pushbit on 9 Feb 2015 at 10:19

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
what is the exact reason for respond 401 error when i am trying to push a 
notification message to gcm server from third party server by using php script? 
:-(

Original comment by ba...@technomobs.com on 13 Feb 2015 at 7:04

GoogleCodeExporter commented 9 years ago
ba...@technomobs.com, I would guess that either you are not using a valid "Key 
for server applications" or that key has restricted "allowed IPs".  This issue 
is only for the method of generating a notification key on Android devices 
using a Google auth token, as described in the instructions linked above.

Original comment by pushbit on 13 Feb 2015 at 9:50