我在登台服务器上从GCM服务器收到Unauthorized
响应,但在使用GCM服务器密钥时不是我的开发服务器。在分段上使用浏览器密钥时,我收到了很好的响应。我想知道原因。
请注意,两个服务器IP都在Google Development Console中列入白名单。两个服务器IP均使用curl ipecho.net/plain
验证。
以下是我的尝试:
开发服务器:
curl --header "Authorization: key=ServerKey" --header Content-Type:"application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"ABC\"]}"
Response (good error): {"multicast_id":7259788225649601706,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}
临时服务器:
curl --header "Authorization: key=ServerKey" --header Content-Type:"application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"ABC\"]}"
Response: (Standard Unauthorized 401 HTML)
我尝试在临时服务器上使用浏览器密钥,但它有效:
curl --header "Authorization: key=BrowserKey" --header Content-Type:"application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"ABC\"]}"
Response (good error): {"multicast_id":7259788225649601706,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"InvalidRegistration"}]}
谁能告诉我为什么?