frthjf / obsidian-zotero-sync-client

A Zotero Sync client for Obsidian
GNU Affero General Public License v3.0
24 stars 3 forks source link

Response parsing fails for certain API key permissions #12

Open ninioArtillero opened 10 months ago

ninioArtillero commented 10 months ago

I've not been able to sync and keep getting the following error:

[Failed to authenticate with Zotero] Cannot read properties of undefined (reading 'all')

I tried different API keys, changing between "library access" and "note access", and also restarting both Zotero and Obsidian to no avail.

I've installed version 1.3.4 from the plugin manager inside Obsidian.

This plugin seems to be exactly what I was looking for my workflow with Obsidian, so I'm excited to make it work. Thanks!

frthjf commented 10 months ago

Could you please try downgrading to v1.3.0 to see if this makes the issue go away. There have been some recent changes (#7) that might cause this issue.

Also, how is your API key permission configured exactly? (see here for more details).

ninioArtillero commented 10 months ago

The API key options I tried involved only Allow library access and Allow notes access checked with default group permissions to None and none Per-group permissions set. Allowing Read Only for default group permission made the sync work. Sorry I didn´t research previous issues for this matter. I don´t have much time lately.

I'll check how the plugin works and perhaps I can install 1.3.0 to see if key without group permission works. How can I install a previous version?

frthjf commented 10 months ago

Ok, so it looks like there is a bug when parsing different library access settings. If it works for you now, there is no need to downgrade. I'll fix it in some future version so group permissions are no longer required.

ulahcherubim commented 4 months ago

Hi, I think I have the same problem. When syncing, if I enter an API key with no group permissions, syncing fails and this message is displayed:

Error: Cannot read properties of undefined (reading 'all') at ZoteroSyncClientPlugin.authenticate (plugin:zotero-sync-client:486:13) at async eval (plugin:zotero-sync-client:820:9)

I don't want to include groups because there are so many items and plugin creates an entry for every one of them even if items don't have any annotations or notes. What is the best way to proceed?

frthjf commented 4 months ago

Thanks for reporting @ulahcherubim. I'll release a fix as soon as possible. In the meantime, you should be able to work around it by adding group permissions and then prevent the note generation for any non-group items by adding something the following to the top of your template:

if ($library.type != 'user') {
  // skip group items.
  return;
}

image