首页 > 解决方案 > 如何将 Slack App 安装商店从本地机器移动到 Amazon S3

问题描述

Slack 应用程序部署在不同的 pod 上触发,之后在 slack 应用程序中,我收到此错误auth.test API 调用结果意外无,我需要再次安装 slack 应用程序。

这是示例代码

oauth_settings = OAuthSettings(
    client_id=os.environ.get('SLACK_CLIENT_ID'),
    client_secret=os.environ.get('SLACK_CLIENT_SECRET'),
    callback_options=callback_options,
    scopes=["channels:read",
            "chat:write",
            "chat:write.public",
            "commands",
            "groups:read",
            "im:history",
            "team:read",
            "users:read",
            "users:read.email"]
)

app = App(
    signing_secret=os.environ.get('SLACK_SIGNING_SECRET'),
    installation_store=FileOAuthStateStore(expiration_seconds=600, base_dir="./data"),
    oauth_settings=oauth_settings

)

标签: amazon-s3slackslack-commands

解决方案


我发现这个解决方案在图书馆中可用,但文档以某种方式丢失

您可以使用 AmazonS3InstallationStore 而不是使用 FileOAuthStateStore

    oauth_settings = OAuthSettings(
    client_id=os.environ.get('SLACK_CLIENT_ID'),
    client_secret=os.environ.get('SLACK_CLIENT_SECRET'),
    callback_options=callback_options,
    scopes=["channels:read",
            "chat:write",
            "chat:write.public",
            "commands",
            "groups:read",
            "im:history",
            "team:read",
            "users:read",
            "users:read.email"]
)

app = App(
    signing_secret=os.environ.get('SLACK_SIGNING_SECRET'),
    installation_store=AmazonS3InstallationStore(s3_client=boto3.client('s3'), bucket_name=os.environ.get('INSTALLATION_BUCKET'), client_id=os.environ.get('SLACK_CLIENT_ID')),
    oauth_settings=oauth_settings

)

确保存储桶不是公开的。这会将松弛安装存储信息存储在此存储桶中


推荐阅读