Client Error: Unauthorized for url

Hey everyone!

Would really appreciate some help:)

My app let’s users upload a pdf, the link to which is then sent to a script on pythonanywhere via a POST request like below:

The problem now is that I am not able to open the files and get this error:
HTTPError: 401 Client Error: Unauthorized for URL

When I copy the link directly from my database and paste it in my browser, I am able to view the file, however, I can see that the URL changes and now includes a AWSAccessKeyId among other parameters.

My question now is, is there a way that I can grant my python script access to the file?

thanks a lot for your help!

Try opening this link in Incognito mode, you should see the same error. Most probably, your file is private, and python script is not authorized and cannot get access to it, while your browser is logged in, so it is authorized.

Thanks for your answer! I do see the same error in incognito mode, however, I thought the file would be public:


I don’t know how you upload this file. Whether private or not is set when file is being uploaded.
You should see it in the file manager, Attached to column.

Thanks so much for your help!

The upload workflow and file manager look like this:


Does this mean I need to allow “View attached files” under User?

Your FileUploader’s Attach To field should indicate which thing you have this file attached to.
If it is empty, then files are attached to Current User.

You can do that, but that’s a bad idea. All files attached to user will become public, if you enable View attached files for unauthenticated users on User thing.
You should change Attach To field of File Uploader to point to the correct thing (Lecure PDF, I suppose). Then next file you will upload, will attach to Lecture PDF, not a User thing. And then you Privacy Settings of the Lecture PDF thing will come into effect.

I think I got it now, thank you! Been stuck on this for days