Bolt-js: Oauth endpoints not created

Created on 18 Aug 2020  路  6Comments  路  Source: slackapi/bolt-js

Description

I followed the documentation here, and I cannot seem to get the oauth module working as is specified. In the docs, it says it sets up the following endpoints:

  • slack/oauth_redirect
  • slack/install

However, it appears neither is actually configured. I followed the default config (subbing in my own configs, of course), and have yet to see it return anything other than a cannot GET... message. Am I perhaps doing something wrong? Are the docs out of date or perhaps showing for a future release? I would love some guidance here.

What type of issue is this? (place an x in one of the [ ])

  • [x] bug?
  • [ ] enhancement (feature request)
  • [x] question
  • [x] documentation related
  • [ ] testing related
  • [ ] discussion

Requirements (place an x in each of the [ ])

  • [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x] I've read and agree to the Code of Conduct.
  • [x] I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: 2.2.3

node version: 14.4

OS version(s): Linux pop-os 5.4.0-7634-generic #38~1592497129~20.04~9a1ea2e-Ubuntu SMP Fri Jun 19 22:43:37 UTC x86_64 x86_64 x86_64 GNU/Linux

Steps to reproduce:

  1. Follow the docs
  2. Attempt to set up redirect
  3. Try to use oauth to authenticate
  4. Cry :cry:

Expected result:

Authentication to work

Actual result:

Great sadness

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

needs info question

Most helpful comment

@stevengill That seems to have worked flawlessly, to anyone copying my config, I also had to remove the token field. Very sorry about this mistake, thanks so much for taking the time to review my error.

All 6 comments

Are you defining your own receiver? If so, the OAuth options (clientId, clientSecret, stateSecrect, etc) need to be passed to ExpressReceiver instead.

const receiver = new ExpressReceiver({ 
  signingSecret: process.env.SLACK_SIGNING_SECRET 
  clientId: process.env.SLACK_CLIENT_ID,
  clientSecret: process.env.SLACK_CLIENT_SECRET
  stateSecret: 'my-state-secret',
  scopes: ['channels:read', 'groups:read', 'channels:manage', 'chat:write', 'incoming-webhook'],
  installationStore: {
    storeInstallation: async (installation) => {
      // change the line below so it saves to your database
      return await database.set(installation.team.id, installation);
    },
    fetchInstallation: async (InstallQuery) => {
      // change the line below so it fetches from your database
      return await database.get(InstallQuery.teamId);
    },
  },
});

const app = new App({
  receiver: receiver,
});


I am not. I just followed the instructions exactly. Is it required to define a custom receiver? I didn't need to do this to use the events endpoint.

@jparr721 it isn't required. It is just a common reason for people to run into issues.

I need a bit more info to help you debug. Can you share your code initializing App?

Once you start your bolt app in terminal, if you go to https://localhost:3000/slack/install in your browser, does it fail?

Yes, I get the cannot GET /slack/install message. Here is my code for initializing:

async function startSlackBot(): Promise<void> {
  const slackPort = dotenvValue(DotenvVariable.SlackPort, '8080');
  const slackClientId = dotenvValue(DotenvVariable.SlackClientId, '');
  const slackSigningSecret = dotenvValue(DotenvVariable.SlackSigningSecret, '');
  const slackbotUserSigningToken = dotenvValue(
    DotenvVariable.SlackbotUserSigningToken,
    '',
  );
  const organizationPrivateKey = dotenvValue(
    DotenvVariable.OrganizationPrivateKey,
    '',
  );

  const bot = new App({
    token: slackbotUserSigningToken,
    signingSecret: slackSigningSecret,
    clientId: slackClientId,
    stateSecret: organizationPrivateKey,
    scopes: ['channels:history', 'reactions:read', 'bot'],
    installationStore: {
      storeInstallation,
      fetchInstallation,
    },
  });

  await bot.start(slackPort);
}

@jparr721 you are missing clientSecret. Try adding that and let me know if it works

@stevengill That seems to have worked flawlessly, to anyone copying my config, I also had to remove the token field. Very sorry about this mistake, thanks so much for taking the time to review my error.

Was this page helpful?
0 / 5 - 0 ratings