GCM api returning 401 suddenly

2,481 views
Skip to first unread message

Sinki Agarwal

unread,
Aug 19, 2016, 1:37:59 AM8/19/16
to android-gcm
I have been using GCM push notifications since the past 2 years with the sender id XXXXXXXXXX and it was working perfectly fine until 11th August,2016.  Starting from 12th August, we have started getting a 401 error (Unauthorized) on our app server side while sending the push notifications. This issue was all of a sudden with absolutely no changes from our side in either the android application or the app server. We checked the validity of the server api key using this link and it gave us "Unauthorized" error. We tried regenerating a new server api key on Google developer console, but the new key also gives the same "Unauthorized" error. So now we are not sure on what the next steps should be. I have ensured that that the "server IP addresses" field on the google developer console is blank. Has anyone faced a similar issue before?


Diego Giorgini

unread,
Aug 19, 2016, 9:00:19 AM8/19/16
to android-gcm
Hi Sinki,

please check that you are using a server type api-key, and not a client api-key.
If you are using Firebase you can find the API-KEY in Project Settings > Cloud Messaging
If you are using cloud console, or you are not sure which key you are using, 
you can generate a new key through through https://console.cloud.google.com 

More documentation see: "Server key" here:

If you are correctly using a server type api-key, but you are still receiving Unauthorized error
please contact the support via: https://support.google.com/code/contact/gcm_dev_support 

Best regards,
- Diego

On Fri, Aug 19, 2016 at 6:38 AM Sinki Agarwal <sinki....@brightlifecare.com> wrote:
I have been using GCM push notifications since the past 2 years with the sender id XXXXXXXXXX and it was working perfectly fine until 11th August,2016.  Starting from 12th August, we have started getting a 401 error (Unauthorized) on our app server side while sending the push notifications. This issue was all of a sudden with absolutely no changes from our side in either the android application or the app server. We checked the validity of the server api key using this link and it gave us "Unauthorized" error. We tried regenerating a new server api key on Google developer console, but the new key also gives the same "Unauthorized" error. So now we are not sure on what the next steps should be. I have ensured that that the "server IP addresses" field on the google developer console is blank. Has anyone faced a similar issue before?


--
You received this message because you are subscribed to the Google Groups "android-gcm" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-gcm...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-gcm/c82fec07-84bc-431d-b6a0-3576bef2e8d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sruthi M

unread,
Sep 9, 2016, 2:19:35 AM9/9/16
to android-gcm
Hi Sinki Agarwal

I too struggling with same problem. Do you find out the any solution.


Thanks and Regards
Sruthi M

JeeJee Studio

unread,
Sep 13, 2016, 3:59:56 PM9/13/16
to android-gcm
Hi, you can also just add the IP of your server to your KEY credentials in gcm. So this IP is allowed to send messages. Then it works again. I had the same.
Its no longer allowed to have an unrestricted Key. So it's not needed to change to Server Key. Or FCM right away.


Op vrijdag 9 september 2016 08:19:35 UTC+2 schreef Sruthi M:

Alvaro Silva

unread,
Oct 6, 2016, 10:30:20 AM10/6/16
to android-gcm
The recent problem was caused by the integration of the Firebase platform, which incorporates the GCM features. After this, the stadard way toregister API keys is not affecting the GCM API anymore. To do so you need to create/link your project inside the Firebase console (https://console.firebase.google.com) and get the SERVER KEY from the Seetings icon on the left panel (Project's Seetings). There you will find the correct API KEY to replace on your servers.
Reply all
Reply to author
Forward
0 new messages