'slack files & url with headers

I'm building a slack bot (python/slack-bolt). Trying to share a private image within the app home tab.

The home tab is genereted using client.views_publish.

{
   "type": "image",
   "title": {
            "type": "plain_text",
            "text": "test image",
             },
   "image_url": "https://files.slack.com/files-pri/<private_ref>/test.jpg",
   "alt_text": "test"
                    },

Now image_url isn't valid as this is a private file. But the file can be accessed via the requests with headers: e.g. this downloads the file correctly:

curl https://files.slack.com/files-pri/<private_ref>/test.jpg --header "Authorization: Bearer <bot_token>" --output test.jpg

How can the url for an image be constructed for the slack blocks so the private image is available to the bot homepage?



Solution 1:[1]


You might have to make the file public shared.
This can be done using following api:
https://api.slack.com/methods/files.sharedPublicURL

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Suyash Gaur