slackapi/bolt-js

issue in getting bot token

Closed this issue · 6 comments

can't able to get bot or user token from fetch installation method from installation store object in bolt.js package . do i need to call any method before running APP instance from bolt.js?

Hello @vadivelJ96. We will need more information to help you. Ensure you have read our documentation about Authenticating with OAuth as a prerequisite.

Are you using a sample installation store provided by Bolt, like the Memory or File store? Or did you implement your own, and if so, did you implement a storeInstallation method?

The way installation store works is that upon your app being installed to a new workspace, as part of the installation OAuth flow, the installation store will run the storeInstallation method of your installation store. We recommend implementing your own and not using the provided sample memory or file store, as they are simplistic and not suitable for production. In any case, storeInstallation should implement a way to persistently store the installation information (like workspace ID and issued access tokens for that workspace); for example, store it to a database. Working in tandem with this method, once your app is installed into a workspace, every event originating from that workspace and sent to your app will trigger your app's fetchInstallation method to retrieve the stored information in order to retrieve the issued access token and be able to interact with your workspace.

How is your receiver initialized?

I see that you are overwriting the POST method to /slack/events - this may be the problem. This is the default route bolt-js uses to receive event payloads from Slack over HTTP (as described in our Getting Started with HTTP docs here). If you are overwriting this route, I would be surprised bolt works at all.

Also, which Request URL (just the path portion is fine) did you configure on your app's configuration page on api.slack.com/apps?

Not sure what to tell you, I tried using the basic example here and it worked fine for me w/ a new app across different workspace installations: https://github.com/slackapi/bolt-js/blob/main/examples/oauth-express-receiver/app.js

Perhaps set the logging level in your receiver and app to DEBUG and inspect the logs to see if that gives you clues as to what is going on.

yes it worked after a few changes.. thanks for your help..!!