New Download URL for attachments

Hi

EDIT: I was able to add Headers (key&token) to the function “image” below. → Solved

I see you finally changes the access to the attachments of the cards. I must now implement the new way of downloading the images asap(!).

As far as I understand, there is no signature anymore in the URL, as the first post “Authenticated Access to S3” explained. I successfully curled the url with key and token in the headers “the new way” as explained.

Right now, I have a nodeJS application which makes a GET request to the board like this:
fetch(https://api.trello.com/1/boards/${BOARDID}/?fields=name,url&key=${KEY}&token=${TOKEN}&cards=visible&lists=open&customFields=true&card_customFieldItems=true&card_attachments=true`)`

And then I iterate over each cards attachments, download and resize one by one, with something like this:
const Image = require("@11ty/eleventy-img"); (async () => { let url = "https://images.unsplash.com/photo-1608178398319-48f814d0750c"; let stats = await Image(url);

How would I download now? I thought I must make a request to each attachment/download, receive an url with the signature and then pass the new url to the download function above… In your announcement your wrote:

If you are using the files directly in your application as a single user, you can add in an API key and token to the request to the /download/ URL.
https://api.trello.com/1/cards/{idCard}/attachments/{idAttachment}/download/{attachmentFileName}

Where exactly must I add the Key/Token as a query-string? I tried:
https://trello.com/1/cards/{idCard}/attachments?key={KEY}&token={TOKEN}/{idAttachment}/download/{fileName}.jpg
→ Says invalid token

I kinda don’t understand why I even have to do this, since I request the whole JSON from the board with a token anyway. I do not use your direct URLs to the attachments publicly, but only downloading and host them myself.

Hope you understand my issue and thanks for a fast response!

Marc

1 Like

Hey Marc, do you mind sharing how you set this code up I’m trying to use HTTP with the following and it doesn’t seem to work.

		HttpRequest->SetHeader("Authorization", "OAuth");
		HttpRequest->SetHeader("oauth_consumer_key", DeveloperKey);
		HttpRequest->SetHeader("oauth_token", AccessToken);