bolt-js
bolt-js copied to clipboard
/slack/install or /slack/oauth_redirect doesn't work.
Default paths such as /slack/install or /slack/oauth_redirect aren't working
Have been following the tutorials but haven't been able to get the default paths such as /slack/install work while using ngrok. Similarly, /slack/oauth_redirect doesn't work. I am not using the manifest file. I have a working app where I can send messages etc and can install the app to my workspace using the App settings page. However, when routing to
What type of issue is this? (place an x
in one of the [ ]
)
- [x] bug
- [ ] enhancement (feature request)
- [ ] question
- [ ] documentation related
- [ ] example code 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:
node version:
OS version(s):
Steps to reproduce:
Expected result:
What you expected to happen
Actual result:
What actually happened
Attachments:
Logs, screenshots, screencast, sample project, funny gif, etc.
Hi @sidgrao, thanks for asking the question!
Could you check the details of following resources and try the same again?
- https://slack.dev/bolt-js/concepts#authenticating-oauth
- https://github.com/slackapi/bolt-js/tree/main/examples/oauth
If you still see issues with your app, sharing a bit more details such as your code that reproduces your situation with us would be helpful. Hope you will figure the cause out soon!
Hi @sidgrao I had a similar issue. My mistake was adding /slack/install
to the redirect URI list on the app management website. Only the redirect URL should go there.
I'm seeing the same as @sidgrao . On Node v18.8.0. None of the /slack/* routes are working. All are 404'ing.
Please check the following resources:
- https://slack.dev/bolt-js/concepts#authenticating-oauth
- https://github.com/slackapi/bolt-js/tree/main/examples/oauth
As long as your app constructor accepts all the necessary settings such as clientId, clientSecret, scopes, and others, the endpoint /slack/install & /slack/oauth_redirect should be available for you.
I'm doing all of those things, and the app isn't handling the route /slack/install
.
Ngrok:
https://MYCUSTOMSUBDOMAIN.ngrok.io -> http://localhost:3000
@cpreid
First off, you can remove token
argument as it is not necessary when you enable the OAuth flow.
And then, please double-check whether the SLACK_ prefixed env variables exist for sure. Lastly, I highly recommend having at least one scope (e.g., chat:write
, commands
) for the OAuth flow. If you don't have any scopes to get approvals from installers, the OAuth flow is totally meaningless (actually, the OAuth redirection to slack.com does not work).
If you are still confused even after checking all above, I would suggest trying the example app as-is first and see what's the difference with your own app code.
The issue is with documentation. This Bolt Dev Doc just states Bolt will support those routes by default. It doesn't clearly indicate that you need to have completed the prior Authenticating OAuth section in order for those routes to work. Having to complete the installationStore
business documented on the right side (pictured below), which shows code referencing a database that a developer realistically wouldn't have ready at this point is quite unintuitive.
Pairing this with the fact that most rudimentary code samples use the hard-coded token: process.env.SLACK_BOT_TOKEN
approach is super confusing.
Furthermore, the default log level for Bolt doesn't indicate what might be taking place when hitting those /slack/*
routes.
I appreciate the feedback! All the points are helpful for us to improve it.
I hope you've already figured out how to configure apps. Whenever you have further questions, please feel free to open a new issue for your specific topics.
Let us close this issue now. If you have any follow-up questions on it, please feel free to write in!
I'm going through the same issue, I've been working on this for weeks and I've read the bolt documentation front to back, the /slack/install
& /slack/oauth_redirect
don't work, I'm getting 404
errors, @cpreid have you fixed your issue? could you help?
here is a my code:
const socketModeReciever = new SocketModeReceiver({
appToken: process.env.SLACK_SOCKET_MODE_TOKEN,
});
export const slackApp = new App({
signingSecret: process.env.SLACK_SIGNING_SECRET,
clientId: process.env.SLACK_CLIENT_ID,
clientSecret: process.env.SLACK_CLIENT_SECRET,
stateSecret: process.env.SLACK_STATE_SECRET,
scopes: appManifest.oauth_config.scopes.user,
receiver: socketModeReciever,
authorize: true,
customRoutes: [
{
path: "/slack/install",
method: ["GET"],
handler: (req, res) => {
res.writeHead(200);
res.end(addToSlackButton);
},
},
],
installationStore: new FileInstallationStore(),
});
@seratch
also as you see I'm using the authorize
param to actually make the code work without the token
, otherwise it will throw an error:
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.
nowhere in the documentation does it say anything about that.
Node Version: v18.12.1
Edit:
I finally fixed the problem, it would seem like I wasn't able to access the routes because the express app that I was using was such as the following:
const app= express();
the Documentation did not make me understand how to work with Express and boltjs, but after researching too much and pulling my hair a bit I finally found that I had to use an ExpressReceiver
from bolt itself and then assign the App
receiver to it like so:
const slackReceiver = new ExpressReceiver({
logLevel: LogLevel.INFO,
signingSecret: process.env.SLACK_SIGNING_SECRET,
clientId: process.env.SLACK_CLIENT_ID,
clientSecret: process.env.SLACK_CLIENT_SECRET,
stateSecret: process.env.SLACK_STATE_SECRET,
scopes: appManifest.oauth_config.scopes.user,
appToken: process.env.SLACK_SOCKET_MODE_TOKEN,
socketMode: true,
installationStore: new FileInstallationStore(),
});
const app = slackReceiver.app;
export const slackApp = new App({
receiver: slackReceiver,
});