How to get a workspace agnostic Slack bot token?

无人久伴 提交于 2019-12-24 15:45:54

问题


I'm trying to create a bot that people can install in their workspaces and send/receive messages of some sort. The problem I'm running into is the documentation tells you to use the token generated for your workspace:

https://api.slack.com/bot-users#installing-bot

But this makes no sense, seeing as people would be installing the App/Bot on their workspace themselves, it's not like they would be giving me their token or anything. Surely I'm missing something. How am I meant to authenticate a bot against whatever workspace it is installed in a purely API driven way?


回答1:


There is no "workspace agnostic" Slack token. Every token is linked to a specific workspace and user.

The usual approach is that you provide an installation routine with Oauth 2.0 for your Slack app. When someone installs your app with that routine a new token is created internally that your app needs to collect and store. This is how every Slack app works.

Note that the installation has to be done once only for each workspace. The token does not expire.

Its simply when you install your Slack app on your own workspace only. That can be done directly from the Slack app management window and requires no installation routine. But then you obviously need to manually copy the generated token to your app.



来源:https://stackoverflow.com/questions/55882545/how-to-get-a-workspace-agnostic-slack-bot-token

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!