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_redirectslack/installHowever, 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.
x in one of the [ ])x in each of the [ ])Filling out the following details about bugs will help us solve your issue sooner.
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
Authentication to work
Great sadness
Logs, screenshots, screencast, sample project, funny gif, etc.
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.
Most helpful comment
@stevengill That seems to have worked flawlessly, to anyone copying my config, I also had to remove the
tokenfield. Very sorry about this mistake, thanks so much for taking the time to review my error.