Hi,
When I consume the GetToken action and passed the scope value as "credential = credential.createScoped(scopes);" and when I pasted the token to send the message I am getting the below error in Postman.
The new FCM URL I tried is https://fcm.googleapis.com/v1/projects/myproject-ProjectID/messages:send as per the documentation. Can you help me on what went wrong and how can i resolve this issue? Thanks
let's inspect the issue you're facing and eliminate all the possibilities.
On your Firebase project settings, make sure you have "Firebase Cloud Messaging API (V1)" enabled.
On your Google Cloud console (click on "Manage Service Accounts") make sure you have generated a service account key.
If you don't, create one using JSON option, once generated use this JSON file on your calls for the Firebase authenticator extension in the ServiceAccountJSON parameter as a binary. You can upload it as a resource on your module.
Once all that is out of the way, now you can use the GetToken action.
If you want to get a token to use it on the messaging API, send this value on the Scopes:"https://www.googleapis.com/auth/firebase.messaging"
Then on the following calls for any endpoint under https://fcm.googleapis.com pass it on the "Authorization" header with the "Bearer " prefix like this:
That should be enough to get the token and authorize your API calls, you can try on Postman with your generated token.
If you're planning to use it on Service Studio, make sure you replace the URL (/v1/projects/palpites-da-loteria-2/messages:send) on the OnBeforeRequest callback.
The OutSystems server performs an encoding on the URL, replacing the ":" with a "%3A".
So create the OnBeforeRequest callback and just create an assignment like this:
CustomizedRequest.URLPath = Replace(Request.URLPath, "%3A", ":")
Otherwise you will get weird runtime errors.
Thanks. After changing the scopes value now I am getting 400 bad request error.
Do I need to change any field in the request?
Below is my current Request payload which we are using.
RegardsBalaji Chandran
Bad request 400 means something's wrong with the request on your side.
If you check the Firebase documentation you'll see that the payload to send messages to specific devices is different than the one you seem to have mapped on your structure:
I suggest you copy this payload and paste on your request body to generate the structure again based on this payload. Check REST API Structures documentation.
Hi Edgar,
Thanks. Let me try this. Because we are using Firebase middleware which will store UserId and RegistrationId together and this is the structure given by them. Now it seems we may need to replace everything along with a token storage. Also may I have some documentation for Sending notification to users with deeplink? Thanks
Check the Firebase documentation for that, there you'll find the step by step to migrate from the old API (which probably firebase middleware uses) to the new one.
Migrate from legacy FCM APIs to HTTP v1