如何将 Slack App 安装存储从本地机器移动到 Amazon S3
How to move Slack App installation store from local machine to Amazon S3
Slack 应用程序部署在不同的 Pod 上触发,之后在 Slack 应用程序中,我收到此错误 auth.test API 调用结果意外 None 我需要重新安装 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
)
确保存储桶不是 public。这会将 slack 安装存储信息存储在此存储桶中
Slack 应用程序部署在不同的 Pod 上触发,之后在 Slack 应用程序中,我收到此错误 auth.test API 调用结果意外 None 我需要重新安装 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
)
确保存储桶不是 public。这会将 slack 安装存储信息存储在此存储桶中