9

参考:http://developer.android.com/google/gcm/demo.html

尝试向我的 android 设备发送消息时出现服务器 401。

HTTP Status 500 - HTTP Status Code: 401

type Exception report

message HTTP Status Code: 401

description The server encountered an internal error (HTTP Status Code: 401) that        prevented it from fulfilling this request.

exception

com.google.android.gcm.server.InvalidRequestException: HTTP Status Code: 401
com.google.android.gcm.server.Sender.sendNoRetry(Sender.java:177)
com.google.android.gcm.server.Sender.send(Sender.java:121)
com.google.android.gcm.demo.server.SendAllMessagesServlet.doPost(SendAllMessagesServ    let.java:83)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.29 logs.

谁能告诉我如何解决?谢谢!

4

1 回答 1

14

您应该查看 GCM 文档,其中解释了 GCM 响应: http: //developer.android.com/google/gcm/gcm.html#response并排除 401 错误代码:http: //developer.android。 com/google/gcm/gcm.html#auth_error

文档中的描述:

身份验证错误 您尝试用于发送邮件的发件人帐户无法通过身份验证。可能的原因有:

授权标头丢失或语法无效。

作为密钥发送的项目编号无效。

密钥有效但 GCM 服务已禁用。

请求来自未在服务器密钥 IP 中列入白名单的服务器。

So I would check to make sure that you are setting you authorization header properly and that you Google Project number is properly setup with GCM and accepting your servers IP.

于 2012-12-22T16:18:12.020 回答