urschrei / pyzotero

Pyzotero: a Python client for the Zotero API
https://pyzotero.readthedocs.org
Other
908 stars 100 forks source link

everything() returns a 403 #15

Closed stakats closed 11 years ago

stakats commented 12 years ago

zot.top() functions fine, but zot.everything(zot.top()) generates a 403 using a private individual library. Is it possible that the API key is being dropped in the everything call? In my script output I see URL: https://api.zotero.org/users//items/top?limit=5&content=json&start=5 with no key appended.

stakats commented 12 years ago

I copied the wrong output URL, but the situation is the same: https://api.zotero.org/users/3/items/top?content=json&start=50

urschrei commented 12 years ago

I wasn't getting a 403, but it was still falling over, due to an unrelated bug. Can you try again using the dev branch?

stakats commented 12 years ago

Tried again with the dev branch and still encountered a 403.

urschrei commented 12 years ago

I can't reproduce this, running v0.9.7 (the latest version on PyPI). I just tried again, and retrieved all 606 items in my library.

Are you running Python 2.7?

stakats commented 12 years ago

Yes, running 0.9.7 with Python 2.7.1. The problem seems to be that when everything() gets to items.extend(self.follow()), it's just chasing down link rel="next" which in my case is https://api.zotero.org/users/3/items/top?content=json&start=50. Since no API key is appended in the next links, it fails.

urschrei commented 12 years ago

I've done some more testing, omitting my API key, and the top() call still works, even though I should be getting an immediate 403. I'll post to zotero-dev before doing anything else, but unless I'm missing something obvious, there are two issues here:

stakats commented 12 years ago

Easily solved: 1) there's a bug in pyzotero; 2) your library is public. If you test with a private library, you'll find the bug.

urschrei commented 12 years ago

Hah. That explains everything.

urschrei commented 12 years ago

OK, commit c8fab2c360451e53935c42c327a1654dd3f167f5 on the dev branch should fix this.