This little script will output the amount of tokens subscribed to a topic.
You will need to replace the variables with your personal ones in order for it to work.
We used this function in a Lambda which sends the results to a monitoring dashboard.
Screenshots in the comments.
-
Go to the Firebase Console.
-
Under Grow click Cloud Messaging.
-
Open up your developer tools.
-
Typ in a fake notification text
-
Click Next
-
Under the Target tab click Topic
-
In the network tab you will see a request to an url similar to this one
https://gcmcontextualcampaign-pa.clients6.google.com/v1/4/projects/${projectId}/topics?prefix=%2Ftopics%2F&key=${key} -
Save your projectId and key in the script
-
Still in the developer tools, under the Application tab go to Cookies
-
Click on the https://console.firebase.google.com site
-
Here you will find the SID, HSID, SSID, APISID and the SAPISID
-
Save these in the script.
I tested it against some other Firebase endpoint. It works as long as you send the 3 cookies starting with __Secure-1. The __Secure-2*** and __Secure-3*** weren't necessary in my experiments (meaning it worked without them).
No idea how to generate __Secure-1PSIDTS since it frequently expires. Supposedly you can get a fresh one by calling accounts.google.com/RotateCookies but I couldn't figure out the correct way to use that endpoint. Would need to dig into the JS that calls this endpoint on the firebase website.