I am trying to send a Firebase Admin push notification from my Atlas trigger.
The Firebase Admin SDK requires initialization by file (i could not find any documentation on how to do differently) so here is the code i have got so far :
const admin = require("firebase-admin");
const json_creds = context.values.get("admin_key");
admin.initializeApp({
credential: admin.credential.cert(json_creds)
});
This throws the following error :
{"message":"Failed to parse service account json file: FunctionError: file not found: { "type": "service_account", "project_id":........}
So i understand from this that admin.credential.cert() takes a file as input and not a String, however in Atlas trigger i have store the value as a secret and linked it to a value to be retrieved from context.values.
To solve my problems i have two different questions :
- How to initialize the firebase admin SDK from the content of the
service_account.jsonand not from file but from an accessibleStringvalue such as an env var i could set in Atlas Trigger ? - OR : How to store a file to be read from the
contextin Atlas Trigger ?
Thanks a lot in advance !