DBus setup for python's keyring module in snap

Trying to make a snap of a Python app that uses “keyring” module. Getting this error:

  File "/snap/buzz-fo/x10/buzz-0.8.1/buzz/gui.py", line 1363, in on_preferences_action_triggered
    preferences_dialog = PreferencesDialog(shortcuts=self.shortcuts, parent=self)
  File "/snap/buzz-fo/x10/buzz-0.8.1/buzz/widgets/preferences_dialog.py", line 24, in __init__
    general_tab_widget = GeneralPreferencesWidget(parent=self)
  File "/snap/buzz-fo/x10/buzz-0.8.1/buzz/widgets/general_preferences_widget.py", line 19, in __init__
    self.openai_api_key = keyring_store.get_password(KeyringStore.Key.OPENAI_API_KEY)
  File "/snap/buzz-fo/x10/buzz-0.8.1/buzz/store/keyring_store.py", line 16, in get_password
    password = keyring.get_password(APP_NAME, username=key.value)
  File "/snap/buzz-fo/x10/lib/python3.10/site-packages/keyring/core.py", line 55, in get_password
    return get_keyring().get_password(service_name, username)
  File "/snap/buzz-fo/x10/lib/python3.10/site-packages/keyring/backends/SecretService.py", line 78, in get_password
    collection = self.get_preferred_collection()
  File "/snap/buzz-fo/x10/lib/python3.10/site-packages/keyring/backends/SecretService.py", line 61, in get_preferred_collection
    collection = secretstorage.get_default_collection(bus)
  File "/snap/buzz-fo/x10/lib/python3.10/site-packages/secretstorage/collection.py", line 177, in get_default_collection
    return Collection(connection)
  File "/snap/buzz-fo/x10/lib/python3.10/site-packages/secretstorage/collection.py", line 45, in __init__
    self._collection.get_property('Label')
  File "/snap/buzz-fo/x10/lib/python3.10/site-packages/secretstorage/util.py", line 67, in get_property
    (signature, value), = self.send_and_get_reply(msg)
  File "/snap/buzz-fo/x10/lib/python3.10/site-packages/secretstorage/util.py", line 48, in send_and_get_reply
    raise DBusErrorResponse(resp_msg)
jeepney.wrappers.DBusErrorResponse: [org.freedesktop.DBus.Error.AccessDenied] ('An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.774" (uid=1000 pid=103789 comm="python /snap/buzz-fo/x10/buzz-0.8.1/main.py " label="snap.buzz-fo.buzz-fo (enforce)") interface="org.freedesktop.DBus.Properties" member="Get" error name="(unset)" requested_reply="0" destination="org.freedesktop.secrets" (uid=1000 pid=2675 comm="/usr/bin/gnome-keyring-daemon --daemonize --login " label="unconfined")',)

What should the right snapcraft YAML config be? Example from docs:

slots:
  dbus-svc: # name that is used with 'snap connect' on slots side
    interface: dbus
    bus: session
    name: org.example.foo

I guess my question is what the name of the slot should be

Fixed by adding password-manager-service plug and connecting it.

1 Like

Try to use snappy-debug in future to get suggestions on what required plugs/slots are missing in the future…

2 Likes

Thanks for saving my day :+1:

1 Like