amazon-s3 - 如何将 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
)
解决方案
我发现这个解决方案在图书馆中可用,但文档以某种方式丢失
您可以使用 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
)
确保存储桶不是公开的。这会将松弛安装存储信息存储在此存储桶中
推荐阅读
- c# - WPF 使用空字符串调用值转换器
- javascript - 如何将数据从 javascript 导入 mongoDB 数据库?
- ffmpeg - 为 sws_scale() 分配 AVFrame
- reactjs - React Native Navigation 自定义边框
- scala - Scala 初始化运行时字段中更改的正确方法:占位符/空,无或零元素?
- c# - 找不到元数据文件 System.dll
- excel - 将 XLSX 转换为 CSV,其中 ImportExcel 在 Powershell 中缺少列
- r - 从整个数据框中删除所有特殊字符但保留因子级别定义
- r - 使用 kableExtra 的多个分组变量
- mongodb - Docker 为 MongoDB ReplicaSet 编写