Save to Zotero fails for pdf behind login firewall - latest zotero 5 standalone
Pdf files supplied by a university (with a login page) or through a proxy can't be imported into zotero when saved from the pdf reader in firefox. Saving the citation from the journal directly attaches the pdf successfully, but many pdfs don't have that option.
Firefox shows "An error occurred while saving this item. Try again, and if the issue persists see..."
And here is the console error message:
```
Error: 401
(1)(+0000004): Error: Downloaded PDF did not have MIME type 'application/pdf' in Attachments.importFromURL()
Error: Downloaded PDF did not have MIME type 'application/pdf' in Attachments.importFromURL()
Zotero.Attachments</this.importFromURL</externalHandlerImport<@chrome://zotero/content/xpcom/attachments.js:336:12
From previous event:
Zotero.Attachments</this.importFromURL</process@chrome://zotero/content/xpcom/attachments.js:410:11
Zotero.Attachments</this.importFromURL<@chrome://zotero/content/xpcom/attachments.js:414:11
From previous event:
Zotero.Server.Connector.SaveSnapshot.prototype.init<@chrome://zotero/content/xpcom/server_connector.js:486:11
From previous event:
Zotero.Server.DataListener.prototype._processEndpoint<@chrome://zotero/content/xpcom/server.js:448:23
From previous event:
Zotero.Server.DataListener.prototype._bodyData@chrome://zotero/content/xpcom/server.js:325:3
Zotero.Server.DataListener.prototype._headerFinished@chrome://zotero/content/xpcom/server.js:297:3
Zotero.Server.DataListener.prototype.onDataAvailable@chrome://zotero/content/xpcom/server.js:201:4
(5)(+0000001): HTTP/1.0 500 Internal Server Error
X-Zotero-Version: 5.0-beta.167+b732a82
X-Zotero-Connector-API-Version: 2
Content-Length: 0
```
Firefox shows "An error occurred while saving this item. Try again, and if the issue persists see..."
And here is the console error message:
```
Error: 401
Forbidden
That action is not authorized. Please ensure that you are authenticated.(1)(+0000004): Error: Downloaded PDF did not have MIME type 'application/pdf' in Attachments.importFromURL()
Error: Downloaded PDF did not have MIME type 'application/pdf' in Attachments.importFromURL()
Zotero.Attachments</this.importFromURL</externalHandlerImport<@chrome://zotero/content/xpcom/attachments.js:336:12
From previous event:
Zotero.Attachments</this.importFromURL</process@chrome://zotero/content/xpcom/attachments.js:410:11
Zotero.Attachments</this.importFromURL<@chrome://zotero/content/xpcom/attachments.js:414:11
From previous event:
Zotero.Server.Connector.SaveSnapshot.prototype.init<@chrome://zotero/content/xpcom/server_connector.js:486:11
From previous event:
Zotero.Server.DataListener.prototype._processEndpoint<@chrome://zotero/content/xpcom/server.js:448:23
From previous event:
Zotero.Server.DataListener.prototype._bodyData@chrome://zotero/content/xpcom/server.js:325:3
Zotero.Server.DataListener.prototype._headerFinished@chrome://zotero/content/xpcom/server.js:297:3
Zotero.Server.DataListener.prototype.onDataAvailable@chrome://zotero/content/xpcom/server.js:201:4
(5)(+0000001): HTTP/1.0 500 Internal Server Error
X-Zotero-Version: 5.0-beta.167+b732a82
X-Zotero-Connector-API-Version: 2
Content-Length: 0
```
http://ac.els-cdn.com.ezp.lib.unimelb.edu.au/S0743016701000031/1-s2.0-S0743016701000031-main.pdf?_tid=54a5ee78-0993-11e7-ba6d-00000aacb35f&acdnat=1489591584_526bd6e44decaf8560184a05d9e5abb7
Just to be clear, while this should work -- and I think we've come across the error of saving PDFs from the connector before -- the recommended way of importing this item would still be to go through
http://www.sciencedirect.com.ezp.lib.unimelb.edu.au/science/article/pii/S0743016701000031
The problem is really when its a pdf from a page with the same issue but without another page with metatdata to download from. Think any papers uploaded by to a university lms. Or sites that require clicking on einstein before download etc. Then its download + drag and drop time, which really isn't the efficient experience I'm used to in Zotero.
https://app.lms.unimelb.edu.au/bbcswebdav/pid-5643447-dt-content-rid-21291811_2/courses/NRMT90014_2017_SM1/Readings/Wiley 2007 Cultures of landscape.pdf
Regarding content on lms. Usually university proxies use cookies, but lms uses Basic Auth, which is kinda weird to work with as it's handled transparently by the browser without being directly exposed for developer access. I have some ideas about how to make it work, but it's a weird corner-case, so no promises for now.
Downloading a pdf to Zotero from the pdf viewer does not work from **any location* that needs my university proxy. Be it LMS, science direct, or any other journal. The journals with human verification are the most annoying, as the publication page zotero button doesn't download the pdf either.
The link is from the pdf itself, but if you click it you will get a redirect to the parent science direct page. But re-clicking on the pdf and downloading from the viewer ***will not work*** through that proxy with the latest zotero 5.0.
Downloading from the publication page of science direct of course works! this is the third time I've said that in this thread. And interesting because it places the issue in your code, not the proxy. If downloading the pdf from the identical url works fine from the publication page, why not the viewer?
With the move to standalone only we have also lost the old "download to zotero" option. That makes this a workflow breaking bug.
Finally, you're talking to a coder like I'm a total newb. I wouldn't post an issue if there wasn't a real, consequential problem with your code.
So how to proceed? do you need login details to test this thing?
I doubt it is just a unimelb specific problem as this all worked in 4.0, and just breaking one proxy seems unlikely.
Works fine in chrome. Broken in firefox. Somehow the connectors are handling this differently.
Different behavior with Chrome & Firefox connector might be a clue -- they're different versions of the connector; the Chrome one is the old code (assuming here you didn't build it from the repo), so unsurprising that it behaves like 4.0.
Just to be sure -- you are using the beta Firefox connector linked to here, right?
https://forums.zotero.org/discussion/comment/267549/#Comment_267549 (I don't think there's another way to connect 5.0 beta to Firefox, but just making sure)
Also, could you try this with all Firefox add-ons, especially privacy-related ones, disabled if you haven't already? And you've made sure that you have fairly permissive cookie settings in Firefox?
Also, non proxied PDFs are saving correctly from Firefox, right?
If you could provide Debug IDs from both Connector side and Standalone side for attempting to save
http://ac.els-cdn.com.ezp.lib.unimelb.edu.au/S0743016701000031/1-s2.0-S0743016701000031-main.pdf?_tid=54a5ee78-0993-11e7-ba6d-00000aacb35f&acdnat=1489591584_526bd6e44decaf8560184a05d9e5abb7
we can take a look, but I am fairly convinced that the problem is Basic Auth, which the connector currently does not support. I've created a ticket to track the issue as it is likely that when 5.0 goes public more people will encounter it. For now this is the first report and we are aware of people successfully using standard cookie based proxies without problems with 5.0
The debug code is D1564969086.
I'm still not sure if that will help with lms. Would be interesting to hear back from you whether that got fixed or not.