How to download submission attachments from the REST API

Hello,

I’m working on an app that should receive submissions throught the REST API of Kobotoolbox.
I receive submissions correctly, but when i try to download attachments for instance by using the provided attachment url download_url property; the HTTP request fails with a 403 Forbidden error.

I think it has to do with authentication because 403 is related to the lake of valid credentials, also when i go in the survey settings and activate “public access” to the form and submissions; i no longer get any auth error, i can download the attachment with no issue.

My question is, how can i keep the security settings activated while being able to download the attachments from my app. Should i pass credentials through the headers of the request? i tried with my login and password using Authorization: Basic …base64-encoded-creds but i still get 403. Perhaps i’m missing something.

FYI: My app is developped in PHP, actually i use the copy() function of PHP to download the attachment.

Any help is welcome, Thank you