I created a Slack app with an admin user (let's call it Admin) and installed it to a workspace (let's call it wspA).
From the app's Messages tab, I'm trying to send a message with an attachment with a different, regular user (let's call it User) and share it to a different workspace (wspB).
When the message event reaches my backend and I call sharedPublicURL with Admin's xoxp token I get a file_not_found error. I did set the files:write user scope.
The code looks something like:
const { WebClient } = require('@slack/web-api');
let client;
const init = () => {
client = new WebClient("<bot's xoxb token>");
};
const forwardToOtherWorkspace = async ({event}) => {
const attachments = await Promise.all(
(event.files || []).map(async file => ({
...
url: await getPublicUrl({ file })
}))
);
// send the attachments to wspB
};
const getPublicUrl = async ({file}) => {
if (file.public_url_shared) {
return file.permalink_public;
}
// this line throws file_not_found with Admin's token, or not_allowed_token_type with Bot's xoxb token
const result = await client.files.sharedPublicURL({ token: "<Admin's xoxp token>" , file: file.id });
// generate public url and return it
};