401 Error after retrieving assets using the request.get_content() method in python
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
-
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,
-Danny0 -
Thanks. Tried it out and it worked. Sorry for the late reply though 😊
0 -
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
0