-
Notifications
You must be signed in to change notification settings - Fork 1
Server Setup
HB-Hridoy edited this page May 26, 2026
·
4 revisions
Follow these instructions carefully to configure and deploy your Google Apps Script as a secure Firebase Cloud Messaging (FCM) sender server.
- Go to the Google Apps Script Home.
- Click on New Project.
- Paste this fcm_sender.js
- Rename your project to something recognizable (e.g.,
FCM Sender Server). - Navigate to the left sidebar and click on Project Settings (the gear icon βοΈ).
- Check the box for Show "appsscript.json" manifest file in editor.
- Return to the Editor tab and open the newly visible
appsscript.jsonfile. - Inside the file configuration, add the script external request field to your
"oauthScopes". - Save the file.
"oauthScopes": [
"https://www.googleapis.com/auth/script.external_request"
]
- Open your main script file (usually
Code.gs). - Paste your server script template into the editor.
- Define your custom
SECRET_KEY.
- Navigate to the Firebase Console.
- Click the gear icon next to "Project Overview" and select Project settings.
- Copy your unique Project ID and paste it into the respective variable within your Apps Script code.
- Inside Firebase Project Settings, switch to the Service accounts tab.
- Scroll down and click the Generate new private key button.
- Confirm and download the resulting
.jsonkey file to your local machine.
- Open the downloaded
.jsonfile, copy its entire contents, and paste it directly into theSERVICE_ACCOUNTobject variable in your script.
- Double-check that all 3 critical variables (
SECRET_KEY,PROJECT_ID, andSERVICE_ACCOUNT) are filled out, then Save the file. - Select the
testSetupfunction from the top toolbar dropdown. - Click Run.
β οΈ Note: On your first execution, Google requires an explicit permissions review. Follow the bypass steps below.
- When the authorization dialog appears, click Review permissions.
- Select your Google Account, then click on the Advanced link at the bottom of the prompt.
- Click the safety bypass link labeled Go to FCM Sender Server (unsafe).
- Review the requested permissions scopes and click Allow / Continue to grant execution rights.
- Check the execution log window at the bottom of your screen.
- If the log displays
FCM response: 400 β’ Auth OK, your environment is fully authorized and properly linked to Firebase.
- Click the Deploy button in the top right corner.
- Choose New deployment from the dropdown menu.
- Click the Gear icon next to Select type.
- Choose Web app from the options list.
Set up your parameters exactly as follows to ensure external accessibility:
-
Description: Add a short note (e.g.,
FCM Sender HTTP v1 API _V1.0.0). - Execute as: Set to Me (your-email).
- Who has access: Set to Anyone.
- Click Deploy.
- Your web server deployment is complete!
- Copy the generated Web app URL from the screen. This URL will serve as your live API endpoint inside your extension configuration.