slackapi/bolt-js

Issue with extracting headers from incoming requests

Closed this issue · 1 comments

(Describe your issue and goal here)

Reproducible in:

The Slack SDK version

^3.17.1

Node.js runtime version

v20.11.0

Hi, I am trying to extract the request headers from all incoming requests following these directions using the customPropertiesExtractor. My code looks something like:

const app = new App({
  receiver: new HTTPReceiver({
    signingSecret: process.env.SLACK_SIGNING_SECRET,
    customPropertiesExtractor: (req) => {
      return {
        "headers": req.headers,
      };
    }
  }),
  signingSecret: ...,
  clientId: ...,
  clientSecret: ...,
  stateSecret: ...,
  scopes: ...,
  installerOptions: {...},
  installationStore: {
   storeInstallation: ...,
   fetchInstallation: ...
  }
});

However, this is throwing an AppInitializationError (I wasn't getting this OAuth error before trying this customPropertiesExtractor code):

1.AppInitializationError(`${tokenUsage} \n\nSince you have not provided a token or authorize, you might be missing one or more required oauth installer options. See https://slack.dev/bolt-js/concepts#authenticating-oauth for these required fields.\n`);

AppInitializationError: Apps used in a single workspace can be initialized with a token. Apps used in many workspaces should be initialized with oauth installer options or authorize. 

Since you have not provided a token or authorize, you might be missing one or more required oauth installer options. See https://slack.dev/bolt-js/concepts#authenticating-oauth for these required fields.

How can I properly extract the request headers from the incoming API calls?

Closed this because I just needed to wrap all the parameters within the HTTPReceiver