Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3663

How to authenticate for FCM Rest API using Google REST API in PHP REST API?

$
0
0

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?

UPDATE::

LINK: Authenticate using Service Account

This API documents on how to authenticate using service accounts. Especially the below lines says the following:

Use credentials to mint access tokens
Unless you are using the Admin SDK, which handle authorization automatically, you'll need to mint the access token and add it to send requests.

Use your Firebase credentials together with the Google Auth Library for your preferred language to retrieve a short-lived OAuth 2.0 access token:

But it does not provide/document any method for minting the short lived access token.


Viewing all articles
Browse latest Browse all 3663

Trending Articles