Unable to download attachment due to permission error | API

So today I tried making an application where I provide a board and list ID. Then, it will get the first card in that list and then get the first attachment, then download it locally. So anyway, it worked all up until the point of downloading the attachment. It said 401 unauthorized. I made it print the url to the attachment, and I could access it fine in my browser (probably because I was logged in.) So my question is, how would I download the attachment, I can provide the token and api key. Or, do I need to grant some certain permissions to my app, here the current permissions are (from my user settings a.k.a Trello):

read and write access on all your boards

read and write access on all your Workspaces

Approved: today at 4:44 PM
Never expires

So what do I have to do?