相关疑难解决方法(0)

GCM http 401授权错误

当我的后端服务器向GCM服务器发送post请求时,我收到HTTP 401的授权错误.

我按照这里描述的步骤:

http://developer.android.com/google/gcm/http.html#auth_error

>> api_key=AIzaSyDEy3...

>> curl --header "Authorization: key=$api_key" --header Content-Type:"application/json" https://android.googleapis.com/gcm/send  -d "{\"registration_id\":\"ABC\"}"
Run Code Online (Sandbox Code Playgroud)

我明白了:

<HTML>
<HEAD>
<TITLE>Unauthorized</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unauthorized</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
Run Code Online (Sandbox Code Playgroud)

在故障排除中它说:

Authentication Error
The sender account that you're trying to use to send a message couldn't be authenticated. Possible causes are:
    1. Authorization header missing or with invalid syntax.
    2. Invalid project number sent as key.
    3. Key valid but with GCM service disabled.
    4. Request originated from a server not …
Run Code Online (Sandbox Code Playgroud)

android push-notification http-status-code-401 google-cloud-messaging

36
推荐指数
6
解决办法
8万
查看次数