-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Several questions regarding code and integrating existing solution with bolt-python. #410
Comments
Hi @Waszker, thanks for asking these questions here! I hope the following answers are helpful to you (and someone who visits this page in the future).
Reading https://api.slack.com/authentication/oauth-v2 should be helpful to understand the basics of the Slack OAuth in general. A Slack app installation can provide two types of OAuth access tokens to your app. They are 1) bot token (xoxb- prefixed) per workspace, and 2) user token (xoxp- prefixed) per user in the installed workspace. In most cases, Slack apps tend to use only bot token scopes. All the end-users in your Slack workspace can use the shared bot's permissions. For instance, using slash commands, shortcuts, modals, message events in channels the bot user is in, and so on can function only with bot token. In other words, bot token scopes can cover most use cases. On the other hand, if your app requests to grant user token scopes (=granting your app to do something on behalf of a user), your app will receive user tokens in addition to a bot token. From an end-user's perspective, the user allows the app to post messages as the user, access private channels, etc by giving a user token.
Th reason why the example app has
For the above reason, we have two types of database tables to cover the mentioned use cases adequately. But if your app does not need to have both, having a single database table for simplicity is also good to go. As recommendations from this project, we don't hesitate having duplicated properties in those two tables. It makes easier to delete data in either of the tables than having relationships in the revocation scenario.
As I mentioned above, you can have only one bot per workspace in installations. This means that, even if 100 users in the workspace installed the same app with bot token scopes, only one bot and its token will be available.
Having the column in a database enables developers to share the same database tables for multiple Slack apps. If that's not your use case, you can remove the column safely.
No, it saves the property this way:
As you mentioned, indeed, the database model does not set the value to
As the default way, we recommend saving all the installation history data with timestamps. Having all-time data can make your troubleshooting / technical investigations in production system operations easier. For instance, your app may need more scopes in the future (say, You app starts with only
If you prefer updating a single database row, that's also the option. It would be a valid choice particularly if you want simplicity in design or have to manage millions/billions of installation events.
I would recommend connecting to
If you are talking abou the
You can use the following APIs as necessary: Let us know if you have some follow-ups here 👋 If you may have many more questions in development and you are happy to join the Slack Community workspace, I can help you there more easily. Joining channels like #tool-bolt, #lang-python, and #slack-api would be recommended. |
👋 Hi @Waszker, let us know if you have anything further to ask/discuss here. We'll close this issue after waiting for your response for a few more days. |
@seratch ooops sorry about lack of response from me - I didn't notice the mention. Your answers were really detailed and sufficient for me - thank you very much for taking your time and answering them. 🙏 |
Hi,
I have created this issue in order to clarify some issues and questions I have regarding the code and the Slack integration approach. I have read official Slack integration document available here: https://api.slack.com/start/building/bolt-python, but there is very little explanation in regards to the internal implementation.
I'm trying to implement Slack integration for the Django-based software that handles multiple user accounts. Each account can request installation of the app to individual Slack workspace (using OAuth), and I have based my current implementation on examples available here: https://github.com/slackapi/bolt-python/tree/main/examples/django/oauth_app
What is the difference between
SlackBot
andSlackInstallation
objects?This is a very basic question but I just can figure out the differences/relation between those two models. When should the installation, and when the bot should be used? Could you point me to some document describing the differences? I see that those two database models share a lot of fields, could this be streamlined, e.g. installation having multiple bots, etc.?
Why store
client_id
value inSlackBot
database object?From what I understand the
client_id
is a sensitive value. It looks like (looking at the example datastore implementation) it is actually never used after saving it in the database (https://github.com/slackapi/bolt-python/blob/main/examples/django/oauth_app/slack_datastores.py#L100). Could this field be omitted, and not stored within a database?Why store multiple instances of bot and installation objects in the database?
I don't understand the idea behind saving new instances of what is essentially the same SlackBot. Would a following code work better, or is there some specific reason multiple instances are required? There could be a unique constraint on (enterprise_id and team_id) pair in the database.
Is it possible to link SlackBot/SlackInstallation object with an internal user account that initiated the app installation?
I would like to know which of my users installed bot. I'd like to add foreign key pointing to User model in the SlackBot, and have it filled in during installation process (taking user from django request object). From what I see, the example
OAuthFlow
object hashandle_callback
method, but is called with slack request instead of django request object.Is it possible to request removal of the installed Slack app?
If the point 4. of this question is not possible, and the user would have to "connect/link" bot from the Slack workspace (e.g. by issuing some command asking for authorization), would it be possible to remove bots that have not been linked after certain period and expire their tokens? I'd like to do this for safety reasons.
Imagine the following situation:
I would like to ensure that the bot token is invalidated during its removal from my database.
The text was updated successfully, but these errors were encountered: