401 Error after retrieving assets using the request.get_content() method in python

Ezekiel
Ezekiel Member Posts: 2

I am getting a 401 error after sending a request to a particular url to download a file. upload works great but downloads return a 401 error.

This is the log message

https://res.cloudinary.com:443 "GET /di8radfle/image/upload/v1734082884/qbrxyfdq1nocm3jwbszx.pdf?API_KEY=<key>&API_SECRET=<secret> HTTP/11" 401 0

I also sent the request without those credentials.

I even used Invoke-WebRequest

And it returned the same error

Invoke-WebRequest : The remote server returned an error: (401) Unauthorized.

Is there anyway around this

Comments

  • DannyFromCloudinary
    DannyFromCloudinary Member, Cloudinary Staff Posts: 154

    Hi @Ezekiel.

    Thanks for getting in touch. It seems there are a couple of things going on here.

    Firstly, you don't want to include your API secret in any GET request to res.cloudinary.com. Not only is this not required, but could also present a security risk if you're exposing your API secret in system logs or across the web.

    Secondly, for security reasons we actually disable delivery of pdf and zip files by default. If you go into your account settings, under 'Product environment settings' you'll see an option for 'Security'. Click into that, and scroll to the bottom, and check the "Allow delivery of PDF and ZIP files" checkbox. This should then allow you to deliver PDF files, and resolve the issue you're facing.

    The delivery URL may be cached, so it might not work straight away, but once that cache expires, delivery should be okay.

    Could you please give that a try and let us know how it goes?

    Many thanks,
    -Danny

  • Ezekiel
    Ezekiel Member Posts: 2

    Thanks. Tried it out and it worked. Sorry for the late reply though 😊

  • Cloudinary Team
    Cloudinary Team Administrator, Cloudinary Staff Posts: 176 admin

    Glad Danny was able to help here. Let us know if there's anything else needed from our team.
    Senior Developer Support Engineer
    Cloudinary


    🧑‍🎓 Academy Training | 📖 Documentation | 📰 Blog