Skip to content

Commit e1971b8

Browse files
author
Horea Porutiu
authored
Add pypi instructions to README (#23)
1 parent 64bebd9 commit e1971b8

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

README.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,45 @@
66
77
# Using the SDK
88

9-
First, you must download the SDK. Please go to the [Releases section](https://github.com/slackapi/python-slack-discovery-sdk/releases). Go ahead and find the latest stable release, and click on the Assets tab to unfurl the assets. Go ahead and download the Source code (either in tar.gz or zip). Go to your Downloads folder, and unzip the source code. Next, open the source code in an editor of your choice, and proceed to the following steps to install the required dependencies.
9+
Use pip to install the SDK.
10+
11+
```bash
12+
pip install slack-discovery-sdk
13+
```
14+
15+
Once you've installed the SDK, you can use the following import statement
16+
to use the methods in the SDK.
17+
18+
```python
19+
from slack_discovery_sdk import DiscoveryClient
20+
```
21+
22+
> Note: use the following command to set your environmental variable to be your token with discovery scopes.
23+
24+
```bash
25+
export SLACK_DISCOVERY_SDK_TEST_ENTERPRISE_TOKEN="your-discovery-token-goes-here"
26+
```
27+
To initialize the SDK, you must pass in a token with Discovery Scopes:
28+
29+
```python
30+
import os
31+
enterprise_token = os.environ["SLACK_DISCOVERY_SDK_TEST_ENTERPRISE_TOKEN"]
32+
client = DiscoveryClient(token=enterprise_token)
33+
```
34+
> Note: Please see the [OAuth guide](https://api.slack.com/enterprise/discovery/oauth-guide) on how to get this token if you don't already have one.
35+
36+
Now, you can use the client to call all of the Slack Discovery SDK methods.
37+
Here is an example of calling the `discovery.enterprise.info` endpoint, and printing the result to the console:
38+
39+
```python
40+
enterprise_info = client.discovery_enterprise_info()
41+
print(enterprise_info.body)
42+
```
43+
44+
To view the full code using the `discovery.enterprise.info` endpoint, please see the sample
45+
[`app.py` file](https://github.com/slackapi/python-slack-discovery-sdk/blob/main/app.py).
46+
47+
To view all of the methods offered by the SDK, please see the [client.py file](https://github.com/slackapi/python-slack-discovery-sdk/blob/main/slack_discovery_sdk/client.py).
1048

1149
# 👨🏻‍💻 Understanding the Setup Script 👩🏻‍💻
1250

app.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@
55

66
logging.basicConfig(level=logging.DEBUG)
77

8-
enterprise_token = os.environ["SLACK_ENTERPRISE_TOKEN"]
9-
10-
# The Bot Token is optional, some customers may not have one
11-
# slack_token = os.environ["SLACK_BOT_TOKEN"]
8+
enterprise_token = os.environ["SLACK_DISCOVERY_SDK_TEST_ENTERPRISE_TOKEN"]
129

1310
client = DiscoveryClient(token=enterprise_token)
1411
enterprise_info = client.discovery_enterprise_info()
15-
print(enterprise_info)
12+
print(enterprise_info.body)
1613

1714
# EXAMPLE USAGE BELOW
1815

1916
auth_test = client.auth_test()
2017
user_conversations = client.discovery_user_conversations(
2118
user=auth_test["user_id"], limit=5
2219
)
23-
print(user_conversations)
20+
print(user_conversations)

0 commit comments

Comments
 (0)