Reputation: 326
It's been a while since I created a Android app with GCM integrated. Previously in the API console you would specify the server IP as a white list. However on my latest project this option is not there. Instead it asks for the SHA1 from the signing key which I have configured.
However when I try to send a notification to a registered device ID I get
"There was an error authenticating the sender account"
I am using the correct API key so I can't see what is wrong.
Upvotes: 0
Views: 3634
Reputation: 3651
Google Cloud Messaging defaults to Firebase Cloud Messaging (FCM) now. Use the Server Key provided in the Firebase Console.
Before that, you may also need to Import your Google Cloud Project into Firebase if you have one.
Import instructions (only follow the "Migrate your console project" section)
Upvotes: 0
Reputation: 17651
Previously in the API console you would specify the server IP as a white list. However on my latest project this option is not there
This section is found when you generate a SERVER API key in your GDC.
"There was an error authenticating the sender account"
Found this on GCM Authentication guide. Make sure these are implemented.
A message request is made of 2 parts: HTTP header and HTTP body.
The HTTP header must contain the following headers:
Authorization: key=YOUR_API_KEY Content-Type: application/json for JSON; application/x-www-form-urlencoded;charset=UTF-8 for plain text. If Content-Type is omitted, the format is assumed to be plain text.
For example:
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
"to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"data" : {
...
},
}
Additional Note:
Authentication Error 401 - The sender account used to send a message couldn't be authenticated.
Possible causes are:
-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. Check that the token you're sending inside the Authentication header is the correct API key associated with your project. See Checking the validity of an API Key for details.
Upvotes: 1