Android GCM Unauthorized 401 error with PHP

孤街醉人 提交于 2020-01-03 13:03:53

问题


Recently my GCM push message notification didn't work anymore. I didn't change anything, in my Google API Console, I've registred the IPV6 of my dedicated server if the whitelist IP address.

But when I try to reach GCM service I always get an error :

Unauthorized

Error 401

Also tried with IPV4 without success...

I've tried the same script on my own computer and everything works smooth ...

Any idea would be very appreciate :)

Thanks for your help


回答1:


You need to put the server IP address in the whitelist ip addresses in google api console for GCM.

Edit: you must use Key for server apps (with IP locking) instead of browser key.




回答2:


i have had the same issue for 1 whole day ! but silly me... in your Dev console>APIs & auth > make sure your "google cloud messaging for android" is ON ! That was my mistake. And also first test by allowing all IPs.




回答3:


I had the same issue. What resolved it for me was registering my public ip, waiting for a few minutes and then refreshing the google api console page.




回答4:


I had the same problem and ended up adding "0::0/0" to my whitelist ip addresses. This fixed the problem for me. Though a better solution would be to get a real IPV6 to use for the server.



来源:https://stackoverflow.com/questions/17164354/android-gcm-unauthorized-401-error-with-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!