{
    "mode": "pydoc",
    "parameter": "secretstorage",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/secretstorage/json",
    "generated": "2026-06-02T15:05:33Z",
    "sections": {
        "NAME": {
            "content": "secretstorage\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This file provides quick access to all SecretStorage API. Please\nrefer to documentation of individual modules for API details.\n",
            "subsections": []
        },
        "PACKAGE CONTENTS": {
            "content": "collection\ndefines\ndhcrypto\nexceptions\nitem\nutil\n",
            "subsections": []
        },
        "CLASSES": {
            "content": "builtins.Exception(builtins.BaseException)\nsecretstorage.exceptions.SecretStorageException\nsecretstorage.exceptions.ItemNotFoundException\nsecretstorage.exceptions.PromptDismissedException\nsecretstorage.exceptions.LockedException\nsecretstorage.exceptions.SecretServiceNotAvailableException\nbuiltins.object\nsecretstorage.collection.Collection\nsecretstorage.item.Item\n",
            "subsections": [
                {
                    "name": "class Collection",
                    "content": "|  Collection(connection: jeepney.io.blocking.DBusConnection, collectionpath: str = '/org/freedesktop/secrets/aliases/default', session: Optional[secretstorage.dhcrypto.Session] = None) -> None\n|\n|  Represents a collection.\n|\n|  Methods defined here:\n|\n|  init(self, connection: jeepney.io.blocking.DBusConnection, collectionpath: str = '/org/freedesktop/secrets/aliases/default', session: Optional[secretstorage.dhcrypto.Session] = None) -> None\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  createitem(self, label: str, attributes: Dict[str, str], secret: bytes, replace: bool = False, contenttype: str = 'text/plain') -> secretstorage.item.Item\n|      Creates a new :class:`~secretstorage.item.Item` with given\n|      `label` (unicode string), `attributes` (dictionary) and `secret`\n|      (bytestring). If `replace` is :const:`True`, replaces the existing\n|      item with the same attributes. If `contenttype` is given, also\n|      sets the content type of the secret (``text/plain`` by default).\n|      Returns the created item.\n|\n|  delete(self) -> None\n|      Deletes the collection and all items inside it.\n|\n|  ensurenotlocked(self) -> None\n|      If collection is locked, raises\n|      :exc:`~secretstorage.exceptions.LockedException`.\n|\n|  getallitems(self) -> Iterator[secretstorage.item.Item]\n|      Returns a generator of all items in the collection.\n|\n|  getlabel(self) -> str\n|      Returns the collection label.\n|\n|  islocked(self) -> bool\n|      Returns :const:`True` if item is locked, otherwise\n|      :const:`False`.\n|\n|  lock(self) -> None\n|      Locks the collection.\n|\n|  searchitems(self, attributes: Dict[str, str]) -> Iterator[secretstorage.item.Item]\n|      Returns a generator of items with the given attributes.\n|      `attributes` should be a dictionary.\n|\n|  setlabel(self, label: str) -> None\n|      Sets collection label to `label`.\n|\n|  unlock(self) -> bool\n|      Requests unlocking the collection.\n|\n|      Returns a boolean representing whether the prompt has been\n|      dismissed; that means :const:`False` on successful unlocking\n|      and :const:`True` if it has been dismissed.\n|\n|      .. versionchanged:: 3.0\n|         No longer accepts the ``callback`` argument.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class Item",
                    "content": "|  Item(connection: jeepney.io.blocking.DBusConnection, itempath: str, session: Optional[secretstorage.dhcrypto.Session] = None) -> None\n|\n|  Represents a secret item.\n|\n|  Methods defined here:\n|\n|  eq(self, other: 'DBusConnection') -> bool\n|      Return self==value.\n|\n|  init(self, connection: jeepney.io.blocking.DBusConnection, itempath: str, session: Optional[secretstorage.dhcrypto.Session] = None) -> None\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  delete(self) -> None\n|      Deletes the item.\n|\n|  ensurenotlocked(self) -> None\n|      If collection is locked, raises\n|      :exc:`~secretstorage.exceptions.LockedException`.\n|\n|  getattributes(self) -> Dict[str, str]\n|      Returns item attributes (dictionary).\n|\n|  getcreated(self) -> int\n|      Returns UNIX timestamp (integer) representing the time\n|      when the item was created.\n|\n|      .. versionadded:: 1.1\n|\n|  getlabel(self) -> str\n|      Returns item label (unicode string).\n|\n|  getmodified(self) -> int\n|      Returns UNIX timestamp (integer) representing the time\n|      when the item was last modified.\n|\n|  getsecret(self) -> bytes\n|      Returns item secret (bytestring).\n|\n|  getsecretcontenttype(self) -> str\n|      Returns content type of item secret (string).\n|\n|  islocked(self) -> bool\n|      Returns :const:`True` if item is locked, otherwise\n|      :const:`False`.\n|\n|  setattributes(self, attributes: Dict[str, str]) -> None\n|      Sets item attributes to `attributes` (dictionary).\n|\n|  setlabel(self, label: str) -> None\n|      Sets item label to `label`.\n|\n|  setsecret(self, secret: bytes, contenttype: str = 'text/plain') -> None\n|      Sets item secret to `secret`. If `contenttype` is given,\n|      also sets the content type of the secret (``text/plain`` by\n|      default).\n|\n|  unlock(self) -> bool\n|      Requests unlocking the item. Usually, this means that the\n|      whole collection containing this item will be unlocked.\n|\n|      Returns a boolean representing whether the prompt has been\n|      dismissed; that means :const:`False` on successful unlocking\n|      and :const:`True` if it has been dismissed.\n|\n|      .. versionadded:: 2.1.2\n|\n|      .. versionchanged:: 3.0\n|         No longer accepts the ``callback`` argument.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Data and other attributes defined here:\n|\n|  hash = None\n"
                },
                {
                    "name": "class ItemNotFoundException",
                    "content": "|  Raised when an item does not exist or has been deleted. Example of\n|  handling:\n|\n|  >>> import secretstorage\n|  >>> connection = secretstorage.dbusinit()\n|  >>> itempath = '/not/existing/path'\n|  >>> try:\n|  ...     item = secretstorage.Item(connection, itempath)\n|  ... except secretstorage.ItemNotFoundException:\n|  ...     print('Item not found!')\n|  ...\n|  Item not found!\n|\n|  Method resolution order:\n|      ItemNotFoundException\n|      SecretStorageException\n|      builtins.Exception\n|      builtins.BaseException\n|      builtins.object\n|\n|  Data descriptors inherited from SecretStorageException:\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.Exception:\n|\n|  init(self, /, *args, kwargs)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from builtins.Exception:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.BaseException:\n|\n|  delattr(self, name, /)\n|      Implement delattr(self, name).\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  reduce(...)\n|      Helper for pickle.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  setattr(self, name, value, /)\n|      Implement setattr(self, name, value).\n|\n|  setstate(...)\n|\n|  str(self, /)\n|      Return str(self).\n|\n|  withtraceback(...)\n|      Exception.withtraceback(tb) --\n|      set self.traceback to tb and return self.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from builtins.BaseException:\n|\n|  cause\n|      exception cause\n|\n|  context\n|      exception context\n|\n|  dict\n|\n|  suppresscontext\n|\n|  traceback\n|\n|  args\n"
                },
                {
                    "name": "class LockedException",
                    "content": "|  Raised when an action cannot be performed because the collection\n|  is locked. Use :meth:`~secretstorage.collection.Collection.islocked`\n|  to check if the collection is locked, and\n|  :meth:`~secretstorage.collection.Collection.unlock` to unlock it.\n|\n|  Method resolution order:\n|      LockedException\n|      SecretStorageException\n|      builtins.Exception\n|      builtins.BaseException\n|      builtins.object\n|\n|  Data descriptors inherited from SecretStorageException:\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.Exception:\n|\n|  init(self, /, *args, kwargs)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from builtins.Exception:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.BaseException:\n|\n|  delattr(self, name, /)\n|      Implement delattr(self, name).\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  reduce(...)\n|      Helper for pickle.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  setattr(self, name, value, /)\n|      Implement setattr(self, name, value).\n|\n|  setstate(...)\n|\n|  str(self, /)\n|      Return str(self).\n|\n|  withtraceback(...)\n|      Exception.withtraceback(tb) --\n|      set self.traceback to tb and return self.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from builtins.BaseException:\n|\n|  cause\n|      exception cause\n|\n|  context\n|      exception context\n|\n|  dict\n|\n|  suppresscontext\n|\n|  traceback\n|\n|  args\n"
                },
                {
                    "name": "class PromptDismissedException",
                    "content": "|  Raised when a prompt was dismissed by the user.\n|\n|  .. versionadded:: 3.1\n|\n|  Method resolution order:\n|      PromptDismissedException\n|      ItemNotFoundException\n|      SecretStorageException\n|      builtins.Exception\n|      builtins.BaseException\n|      builtins.object\n|\n|  Data descriptors inherited from SecretStorageException:\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.Exception:\n|\n|  init(self, /, *args, kwargs)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from builtins.Exception:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.BaseException:\n|\n|  delattr(self, name, /)\n|      Implement delattr(self, name).\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  reduce(...)\n|      Helper for pickle.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  setattr(self, name, value, /)\n|      Implement setattr(self, name, value).\n|\n|  setstate(...)\n|\n|  str(self, /)\n|      Return str(self).\n|\n|  withtraceback(...)\n|      Exception.withtraceback(tb) --\n|      set self.traceback to tb and return self.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from builtins.BaseException:\n|\n|  cause\n|      exception cause\n|\n|  context\n|      exception context\n|\n|  dict\n|\n|  suppresscontext\n|\n|  traceback\n|\n|  args\n"
                },
                {
                    "name": "class SecretServiceNotAvailableException",
                    "content": "|  Raised by :class:`~secretstorage.item.Item` or\n|  :class:`~secretstorage.collection.Collection` constructors, or by\n|  other functions in the :mod:`secretstorage.collection` module, when\n|  the Secret Service API is not available.\n|\n|  Method resolution order:\n|      SecretServiceNotAvailableException\n|      SecretStorageException\n|      builtins.Exception\n|      builtins.BaseException\n|      builtins.object\n|\n|  Data descriptors inherited from SecretStorageException:\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.Exception:\n|\n|  init(self, /, *args, kwargs)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from builtins.Exception:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.BaseException:\n|\n|  delattr(self, name, /)\n|      Implement delattr(self, name).\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  reduce(...)\n|      Helper for pickle.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  setattr(self, name, value, /)\n|      Implement setattr(self, name, value).\n|\n|  setstate(...)\n|\n|  str(self, /)\n|      Return str(self).\n|\n|  withtraceback(...)\n|      Exception.withtraceback(tb) --\n|      set self.traceback to tb and return self.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from builtins.BaseException:\n|\n|  cause\n|      exception cause\n|\n|  context\n|      exception context\n|\n|  dict\n|\n|  suppresscontext\n|\n|  traceback\n|\n|  args\n"
                },
                {
                    "name": "class SecretStorageException",
                    "content": "|  All exceptions derive from this class.\n|\n|  Method resolution order:\n|      SecretStorageException\n|      builtins.Exception\n|      builtins.BaseException\n|      builtins.object\n|\n|  Data descriptors defined here:\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.Exception:\n|\n|  init(self, /, *args, kwargs)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from builtins.Exception:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.BaseException:\n|\n|  delattr(self, name, /)\n|      Implement delattr(self, name).\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  reduce(...)\n|      Helper for pickle.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  setattr(self, name, value, /)\n|      Implement setattr(self, name, value).\n|\n|  setstate(...)\n|\n|  str(self, /)\n|      Return str(self).\n|\n|  withtraceback(...)\n|      Exception.withtraceback(tb) --\n|      set self.traceback to tb and return self.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from builtins.BaseException:\n|\n|  cause\n|      exception cause\n|\n|  context\n|      exception context\n|\n|  dict\n|\n|  suppresscontext\n|\n|  traceback\n|\n|  args\n"
                }
            ]
        },
        "FUNCTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "check_service_availability",
                    "content": "Returns True if the Secret Service daemon is either running or\navailable for activation via D-Bus, False otherwise.\n\n.. versionadded:: 3.2\n"
                },
                {
                    "name": "create_collection",
                    "content": "Creates a new :class:`Collection` with the given `label` and `alias`\nand returns it. This action requires prompting.\n\n:raises: :exc:`~secretstorage.exceptions.PromptDismissedException`\nif the prompt is dismissed.\n"
                },
                {
                    "name": "dbus_init",
                    "content": "Returns a new connection to the session bus, instance of\njeepney's :class:`DBusConnection` class. This connection can\nthen be passed to various SecretStorage functions, such as\n:func:`~secretstorage.collection.getdefaultcollection`.\n\n.. warning::\nThe D-Bus socket will not be closed automatically. You can\nclose it manually using the :meth:`DBusConnection.close` method,\nor you can use the :class:`contextlib.closing` context manager:\n\n.. code-block:: python\n\nfrom contextlib import closing\nwith closing(dbusinit()) as conn:\ncollection = secretstorage.getdefaultcollection(conn)\nitems = collection.searchitems({'application': 'myapp'})\n\nHowever, you will not be able to call any methods on the objects\ncreated within the context after you leave it.\n\n.. versionchanged:: 3.0\nBefore the port to Jeepney, this function returned an\ninstance of :class:`dbus.SessionBus` class.\n\n.. versionchanged:: 3.1\nThis function no longer accepts any arguments.\n"
                },
                {
                    "name": "get_all_collections",
                    "content": "Returns a generator of all available collections.\n"
                },
                {
                    "name": "get_any_collection",
                    "content": "Returns any collection, in the following order of preference:\n\n- The default collection;\n- The \"session\" collection (usually temporary);\n- The first collection in the collections list.\n"
                },
                {
                    "name": "get_collection_by_alias",
                    "content": "Returns the collection with the given `alias`. If there is no\nsuch collection, raises\n:exc:`~secretstorage.exceptions.ItemNotFoundException`.\n"
                },
                {
                    "name": "get_default_collection",
                    "content": "Returns the default collection. If it doesn't exist,\ncreates it.\n"
                },
                {
                    "name": "search_items",
                    "content": "Returns a generator of items in all collections with the given\nattributes. `attributes` should be a dictionary.\n"
                }
            ]
        },
        "DATA": {
            "content": "all = ['Collection', 'Item', 'ItemNotFoundException', 'LockedExcep...\nversiontuple = (3, 3, 1)\n",
            "subsections": []
        },
        "VERSION": {
            "content": "3.3.1\n",
            "subsections": []
        },
        "FILE": {
            "content": "/usr/lib/python3/dist-packages/secretstorage/init.py\n\n",
            "subsections": []
        }
    },
    "summary": "secretstorage",
    "flags": [],
    "examples": [],
    "see_also": []
}