I already tried so many solutions there to solve it.
Have a lot of unsolved questions here (on stackoverflow) finding for same solution.
When I call:
curl --header "Authorization: key=MY_KEY" --header "Content-Type: application/json" https://android.googleapis.com/gcm/send -d "{\"registration_ids\":[\"THE_ID\"]}"
I'm got:
<HTML>
<HEAD>
<TITLE>Unauthorized</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Unauthorized</H1>
<H2>Error 401</H2>
</BODY>
</HTML>
The problem is: every solution here on stackoverflow says "Use the server key, not the browser key". On the current console, when I create a server key, it showme some options and I'm not sure if it right.
Course, I already created some of then. It creates a json file to download, with some data on it... but I really don't know WHERE ARE the SERVER KEY.
What key should I use and where to get it exactly ?
The "create credential" option, where I choose the third one:
The two options to create a server key:
TL;DR:
To create a sender-id
and server-key
for GCM or FCM you can use the Firebase Console.
New projects should be created directly in Firebase Console, while existing Cloud Console projects can be imported using Import Google Project from the main page: http://console.firebase.google.com
Once you have a firebase project you can find the GCM / FCM credentials in
Project Setting > Cloud Messaging
More informations:
After importing a Google Project into Firebase the same project will be accessible from both the Cloud Console and the Firebase Console. What changes is that you also have access to the Firebase API.
While we strongly recommended to update the client SDK to Firebase Cloud Messaging, the credentials listed under Project Settings > Cloud Messaging
can be used in GCM too.