Is there any reason why the GCM (Google Cloud Messaging) Service from Google suddenly returns a 401 for a request to send an Android push notification? The call looks like this
curl --header "Authorization: key=<my_android_key>" --header Content-Type:"application/json" https://android.googleapis.com/gcm/send -d "{\"to\":\"/topics/my_topic\", \"data\":{\"category\":\"help\", \"title\":\"Test\", \"text\":\"Test\", \"param\":\"\"}}"
The result is
<HTML>
<HEAD>
<TITLE>Unauthorized</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unauthorized</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
UPDATE:
Google names four possible causes for this error:
- Authorization header missing or with invalid syntax in HTTP request.
- Invalid project number sent as key
- Key valid but with GCM service disabled.
- Request originated from a server not whitelisted in the Server Key IPs.
I checked the validity of the API key in question here, and it seems to be invalid. The question is why? It used to work so far. Argh. :-/