async function checkAccessTokenAndEnt()

in src/utils/configUtils.js [541:576]


async function checkAccessTokenAndEnt(
  accessToken: string,
  entID: string,
  entKey: string,
  fields: Array<string> = ['id'],
): Promise<Object> {
  try {
    return await graphAPI(
      entID,
      'GET',
      {
        access_token: accessToken,
        fields,
      },
    );
  } catch (error) {
    const erorrDetails = {
      message: error.message,
      type: error.type,
      code: error.code,
      fbtrace_id: error.fbtrace_id,
    };
    winston.error(
      `Failed to read ${entID} using access token ${accessToken}, receiving `
      + `error: ${JSON.stringify(erorrDetails)}. \n`
      + `Please make sure ${entKey} and accessToken are setup properly. `
      + 'Also, network or firewall issues may also cause the error. '
      + 'Please make sure your network is connected and whitelist Facebook '
      + 'API server IPs in your firewall settings. Use '
      + '`whois -h whois.radb.net -- \'-i origin AS32934\' | grep ^route` '
      + 'to list all Facebook IPs.'
    );
    process.exit(1);
    throw error;
  }
}