I need to send a notification using FCM REST API. However, I am unable to authenticaate using an API key at the moment. The below is the API to hit.
https://fcm.googleapis.com/v1/projects/proj-name/messages:send?key=XXX
The error I receive is as follows:
{
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
The backend is in PHP so there isn’t any supported package for it. Hence, I am trying to use it for sending the notification. The above API seem to take oauth 2 access token or login cookie or some auther vaidation method. However, I need to send it from my own REST API. How can I authenticate from PHP to the above API and send the notificaiton properly?