|
1 | 1 | import json |
2 | 2 | import os |
3 | 3 | from pathlib import Path |
4 | | -from urllib.parse import urljoin |
5 | | -from dotenv import load_dotenv |
6 | 4 |
|
7 | | - |
8 | | -from slack_bolt.oauth.oauth_settings import OAuthSettings |
| 5 | +from slack_sdk.oauth import AuthorizeUrlGenerator |
9 | 6 | from slack_sdk.oauth.installation_store import FileInstallationStore |
10 | 7 | from slack_sdk.oauth.state_store import FileOAuthStateStore |
11 | 8 |
|
12 | | -load_dotenv(dotenv_path=".env", override=False) |
13 | | - |
14 | 9 | _manifest = json.loads(Path("manifest.json").read_text()) |
15 | 10 | BOT_SCOPES = _manifest["oauth_config"]["scopes"]["bot"] |
16 | 11 |
|
|
25 | 20 | "users:read", |
26 | 21 | ] |
27 | 22 |
|
28 | | -oauth_settings = OAuthSettings( |
29 | | - client_id=os.environ.get("SLACK_CLIENT_ID"), |
30 | | - client_secret=os.environ.get("SLACK_CLIENT_SECRET"), |
31 | | - redirect_uri=os.environ.get("SLACK_REDIRECT_URI"), |
| 23 | +installation_store = FileInstallationStore( |
| 24 | + base_dir="./data/installations", |
| 25 | + historical_data_enabled=False, |
| 26 | +) |
| 27 | + |
| 28 | +state_store = FileOAuthStateStore( |
| 29 | + expiration_seconds=600, |
| 30 | + base_dir="./data/states", |
| 31 | +) |
| 32 | + |
| 33 | +authorize_url_generator = AuthorizeUrlGenerator( |
| 34 | + client_id=os.environ.get("SLACK_CLIENT_ID", ""), |
| 35 | + redirect_uri=os.environ.get("SLACK_REDIRECT_URI", ""), |
32 | 36 | scopes=BOT_SCOPES, |
33 | 37 | user_scopes=USER_SCOPES, |
34 | | - installation_store=FileInstallationStore( |
35 | | - base_dir="./data/installations", |
36 | | - ), |
37 | | - state_store=FileOAuthStateStore( |
38 | | - expiration_seconds=600, |
39 | | - base_dir="./data/states", |
40 | | - ), |
41 | 38 | ) |
42 | | -install_uri = urljoin(oauth_settings.redirect_uri, oauth_settings.install_path) |
0 commit comments