Skip to content

Commit ed7ef1f

Browse files
committed
Update Django example app - ref #324
1 parent e1b7a6f commit ed7ef1f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

examples/django/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
Follow the instructions [here](https://slack.dev/bolt-python/concepts#authenticating-oauth) for configuring OAuth flow supported Slack apps. This example works with the default env variables such as `SLACK_CLIENT_ID`, `SLACK_CLIENT_SECRET`, `SLACK_SCOPES`, `SLACK_SIGNING_SECRET`, and so forth.
2+
13
```
24
pip install -r requirements.txt
3-
export SLACK_SIGNING_SECRET=***
4-
export SLACK_BOT_TOKEN=xoxb-***
5+
export SLACK_CLIENT_ID=
6+
export SLACK_CLIENT_SECRET=
7+
export SLACK_SCOPES=commands.chat:write
8+
export SLACK_SIGNING_SECRET=
59
610
python manage.py migrate
711
python manage.py runserver 0.0.0.0:3000

examples/django/slackapp/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,11 @@ def consume(self, state: str) -> bool:
231231
from slack_bolt.oauth.oauth_settings import OAuthSettings
232232

233233
logger = logging.getLogger(__name__)
234-
client_id, client_secret, signing_secret = (
234+
client_id, client_secret, signing_secret, scopes = (
235235
os.environ["SLACK_CLIENT_ID"],
236236
os.environ["SLACK_CLIENT_SECRET"],
237237
os.environ["SLACK_SIGNING_SECRET"],
238+
os.environ.get("SLACK_SCOPES", "commands").split(","),
238239
)
239240

240241
app = App(
@@ -246,6 +247,7 @@ def consume(self, state: str) -> bool:
246247
oauth_settings=OAuthSettings(
247248
client_id=client_id,
248249
client_secret=client_secret,
250+
scopes=scopes,
249251
state_store=DjangoOAuthStateStore(
250252
expiration_seconds=120,
251253
logger=logger,

0 commit comments

Comments
 (0)