FCM Cloud Messaging – Provide Credentials Manually

In attempting to follow the instructions detailed at https://firebase.google.com/docs/cloud-messaging/migrate-v1?authuser=2#provide-credentials-manually, I’m getting

Error sending message: Error: exec is not supported

I think the issue lies in something needing to be changed for the manual approach, but aside from adding the headers section to the message I don’t know what to do.

Regarding the code below, assume that getAccessToken() is implemented and verified to be working properly, and I’m aware that registrationToken is defined such that an invalid token error should be rendered, the entire issue is that I’m not getting to that error as expected.

const { JWT } = require('google-auth-library');
const admin = require('firebase-admin');

exports = async function(){

  var accessToken = getAccessToken();

  admin.initializeApp();

  // This registration token comes from the client FCM SDKs.
  const registrationToken = 'YOUR_REGISTRATION_TOKEN';
  
  const message = {
    headers: {
      'Authorization': 'Bearer ' + accessToken
    },
    notification: {
      title: 'Test title',
      body: 'You need to X!'
    },
    token: registrationToken
  };
  
  // Send a message to the device corresponding to the provided
  // registration token.
  admin.messaging().send(message)
    .then((response) => {
      // Response is a message ID string.
      console.log('Successfully sent message:', response);
    })
    .catch((error) => {
      console.log('Error sending message:', error);
    });
  
};