How to get temporary link for public user (no access to our board) to download an attachment

I am currently trying to obtain a url to automatically download attachments from specific cards on a private board. I see from Update: Authenticated Access to S3 that attachments used to have public URLs, but now the only way to get a public link is via a GET request, to which a temporary (1 hour) link is returned with a signature.

I have followed the steps, however, I am only returned a JSON with a private link (no signature attached). Does anyone know what I am missing here? Any help is much appreciated!

Here is a snippet for the relevant parts of the code (Python): (Note that url is the trello api url)

path = '/1/cards/{cardId}/attachments/{attachmentId}

ar = requests.get(url = url + path, params = params)

The URL from the response is as follows, which is only accessible with proper login credentials:

‘url’: ‘{cardId}/attachments/{attachmentId}/download/{filename}

Check out this specific part in the update:

The /download/ URL format is the following:{idCard}/attachments/{idAttachment}/download/{attachmentFileName}

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.

Don’t forget that the key and token cannot be passed in the URL anymore. It needs to be done with the oauth 1.0 method.

I’ll try to get an example posted soon for you.

Thank you for your quick response!

I adjusted my code as you had mentioned (I think I am doing oauth 1.0 correctly…), however, it seems like it is now returning a blank JSON.

Please note the updated code below, where downloadImgUrl is in the format:{cardId}/attachments/{attachmentId}/download/{filename}

from requests_oauthlib import OAuth1Session
trello = OAuth1Session(key, secret, oauthtoken)

test = trello.get(downloadImgUrl)
print(test.json()) ← JSONDecodeError: Expecting value

Without running a test myself right now (time constraints), what does just simply print(test) reveal?

Also, are you something like Postman or Insomnia for testing? I find it’s easier to run my calls through those first so I know they work before I drop them into my actual code base.

I recommend Insomnia as I have experienced issues with Postman not sending OAuth1.0 correctly (there are several complaints about it on their forums).

Noted on running through Postman/Insomnia first for next time!

I have figured out that since the dl file is a pdf, it would not show as a JSON (had to do test.content to see results). I then simply saved it locally using the below code. Thank you for your help!

from pathlib import Path

filename = Path(‘testfile.pdf’)