Last active
June 12, 2023 12:15
-
-
Save ErikKalkoken/f3ab28617d5099531ded865d111dbac1 to your computer and use it in GitHub Desktop.
Fetch a private file from Slack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# fetching a private Slack file with requests | |
import requests | |
import os | |
slack_token = os.environ['SLACK_TOKEN'] | |
url = 'https://files.slack.com/files-pri/T12345678-F12345678/my_file.jpg' | |
res = requests.get(url, headers={'Authorization': f'Bearer {slack_token}'}) | |
res.raise_for_status() | |
with open('my_file.jpg', 'wb') as f: | |
f.write(res.content) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's a mistake in this code:
You are missing
f
in L9{f'Authorization': f'Bearer {slack_token}'})