简体   繁体   English

Google Cloud Messaging未经授权

[英]Google Cloud Messaging Unauthorized

I am working on an application that can receive notifications using Google Cloud Messaging. 我正在开发一个可以使用Google Cloud Messaging接收通知的应用程序。 I implemented it following Google's instructions and it worked. 我按照Google的指示实施了该工具,并成功了。 For the server side implementation of Google Cloud Messaging, I used a PHP webserver. 对于Google Cloud Messaging的服务器端实现,我使用了PHP Web服务器。

I am having trouble switching from webserver. 我无法从网络服务器切换。 I switched from a http server to a https server. 我从http服务器切换到https服务器。 This https server has a different IP address then the http server. 此https服务器的IP地址与http服务器的IP地址不同。

In the Google Developer console, I edited the allowed IP addresses for the server key to the new https server ip. 在Google Developer Console中,我将服务器密钥的允许IP地址编辑为新的https服务器ip。 I applied the settings, but now I am getting the following error when trying to send a notification to Google Cloud Messaging: 我应用了设置,但是现在尝试向Google Cloud Messaging发送通知时出现以下错误:

Unauthorized Error 401 未经授权的错误401

I also tried deleting the server key and regenerating one. 我也尝试删除服务器密钥并重新生成一个。 When I used this new key in my php code, I got the same error. 当我在php代码中使用此新密钥时,出现了相同的错误。

I searched StackOverflow for answers. 我在StackOverflow搜索了答案。 There are a lot of questions containing the unauthorized issue with Google Cloud Messaging. 有很多问题包含Google Cloud Messaging的未授权问题。 In most of these cases, people were using an android key instead of a server key. 在大多数情况下,人们使用的是Android密钥而不是服务器密钥。 Note that I am using a server key already. 请注意,我已经在使用服务器密钥。

Everything has worked, just until I switched IP-address. 一切正常,直到我切换了IP地址。

What could be the issue here? 这里可能是什么问题?

I removed the entered IP-address in the Google Developer console so that it is now set to 'Any IP allowed' and now it works. 我在Google Developer控制台中删除了输入的IP地址,因此现在将其设置为“允许使用任何IP”,并且现在可以使用了。 This is very weird, as the IP-address I entered was 100% correct. 这很奇怪,因为我输入的IP地址是100%正确。 I'm guessing this is a problem related to Google itself. 我猜这是与Google本身有关的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM