Secret.Service¶
- Subclasses:
None
Methods¶
- Inherited:
Gio.DBusProxy (25), GObject.Object (37), Gio.AsyncInitable (4), Gio.DBusInterface (3), Gio.Initable (2), Secret.Backend (2)
- Structs:
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Gio.DBusProxy (2), GObject.Object (7), Gio.AsyncInitable (2), Gio.DBusInterface (3), Gio.Initable (1), Secret.Backend (9)
|
|
|
|
|
Properties¶
- Inherited:
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class Secret.Service(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A proxy object representing the Secret Service.
A
Secret.Service
object represents the Secret Service implementation which runs as a D-Bus service.Normally a single
Secret.Service
object can be shared between multiple callers. The [func`Service`.get] method is used to access thisSecret.Service
object. If a new independentSecret.Service
object is required, use [func`Service`.open].In order to securely transfer secrets to the Sercret Service, a session is established. This session can be established while initializing a
Secret.Service
object by passing theSecret.ServiceFlags.OPEN_SESSION
flag to the [func`Service`.get] or [func`Service`.open] functions. In order to establish a session on an already existingSecret.Service
, use the [method`Service`.ensure_session] function.To search for items, use the [method`Service`.search] method.
Multiple collections can exist in the Secret Service, each of which contains secret items. In order to instantiate [class`Collection`] objects which represent those collections while initializing a
Secret.Service
then pass theSecret.ServiceFlags.LOAD_COLLECTIONS
flag to the [func`Service`.get] or [func`Service`.open] functions. In order to establish a session on an already existingSecret.Service
, use the [method`Service`.load_collections] function. To access the list of collections use [method`Service`.get_collections].Certain actions on the Secret Service require user prompting to complete, such as creating a collection, or unlocking a collection. When such a prompt is necessary, then a [class`Prompt`] object is created by this library, and passed to the [method`Service`.prompt] method. In this way it is handled automatically.
In order to customize prompt handling, override the [vfunc`Service`.prompt_async] and [vfunc`Service`.prompt_finish] virtual methods of the
Secret.Service
class.- classmethod disconnect()¶
Disconnect the default
Secret.Service
proxy returned by [func`Service`.get] and [func`Service`.get_sync].It is not necessary to call this function, but you may choose to do so at program exit. It is useful for testing that memory is not leaked.
This function is safe to call at any time. But if other objects in this library are still referenced, then this will not result in all memory being freed.
- classmethod get(flags, cancellable, callback, *user_data)¶
- Parameters:
flags (
Secret.ServiceFlags
) – flags for which service functionality to ensure is initializedcancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completesuser_data (
object
orNone
) – data to be passed to the callback
Get a
Secret.Service
proxy for the Secret Service.If such a proxy object already exists, then the same proxy is returned.
If flags contains any flags of which parts of the secret service to ensure are initialized, then those will be initialized before completing.
This method will return immediately and complete asynchronously.
- classmethod get_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – the asynchronous result passed to the callback- Raises:
- Returns:
a new reference to a
Secret.Service
proxy, which should be released with [method`GObject`.Object.unref].- Return type:
Complete an asynchronous operation to get a
Secret.Service
proxy for the Secret Service.
- classmethod get_sync(flags, cancellable)¶
- Parameters:
flags (
Secret.ServiceFlags
) – flags for which service functionality to ensure is initializedcancellable (
Gio.Cancellable
orNone
) – optional cancellation object
- Raises:
- Returns:
a new reference to a
Secret.Service
proxy, which should be released with [method`GObject`.Object.unref].- Return type:
Get a
Secret.Service
proxy for the Secret Service.If such a proxy object already exists, then the same proxy is returned.
If flags contains any flags of which parts of the secret service to ensure are initialized, then those will be initialized before returning.
This method may block indefinitely and should not be used in user interface threads.
- classmethod open(service_gtype, service_bus_name, flags, cancellable, callback, *user_data)¶
- Parameters:
service_gtype (
GObject.GType
) – theGObject.GType
of the new secret serviceservice_bus_name (
str
orNone
) – the D-Bus service name of the secret serviceflags (
Secret.ServiceFlags
) – flags for which service functionality to ensure is initializedcancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completesuser_data (
object
orNone
) – data to be passed to the callback
Create a new
Secret.Service
proxy for the Secret Service.This function is rarely used, see [func`Service`.get] instead.
The service_gtype argument should be set to %SECRET_TYPE_SERVICE or a the type of a derived class.
If flags contains any flags of which parts of the secret service to ensure are initialized, then those will be initialized before returning.
If service_bus_name is
None
then the default is used.This method will return immediately and complete asynchronously.
- classmethod open_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – the asynchronous result passed to the callback- Raises:
- Returns:
a new reference to a
Secret.Service
proxy, which should be released with [method`GObject`.Object.unref].- Return type:
Complete an asynchronous operation to create a new
Secret.Service
proxy for the Secret Service.
- classmethod open_sync(service_gtype, service_bus_name, flags, cancellable)¶
- Parameters:
service_gtype (
GObject.GType
) – theGObject.GType
of the new secret serviceservice_bus_name (
str
orNone
) – the D-Bus service name of the secret serviceflags (
Secret.ServiceFlags
) – flags for which service functionality to ensure is initializedcancellable (
Gio.Cancellable
orNone
) – optional cancellation object
- Raises:
- Returns:
a new reference to a
Secret.Service
proxy, which should be released with [method`GObject`.Object.unref].- Return type:
Create a new
Secret.Service
proxy for the Secret Service.This function is rarely used, see [func`Service`.get_sync] instead.
The service_gtype argument should be set to %SECRET_TYPE_SERVICE or a the type of a derived class.
If flags contains any flags of which parts of the secret service to ensure are initialized, then those will be initialized before returning.
If service_bus_name is
None
then the default is used.This method may block indefinitely and should not be used in user interface threads.
- clear(schema, attributes, cancellable, callback, *user_data)¶
- Parameters:
schema (
Secret.Schema
orNone
) – the schema for the attributescancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completesuser_data (
object
orNone
) – data to be passed to the callback
Remove unlocked items which match the attributes from the secret service.
The attributes should be a set of key and value string pairs.
If self is
None
, then [func`Service`.get] will be called to get the default [class`Service`] proxy.This method will return immediately and complete asynchronously.
- clear_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – the asynchronous result passed to the callback- Raises:
- Returns:
whether items were removed or not
- Return type:
Finish asynchronous operation to remove items from the secret service.
- clear_sync(schema, attributes, cancellable)¶
- Parameters:
schema (
Secret.Schema
orNone
) – the schema for the attributescancellable (
Gio.Cancellable
orNone
) – optional cancellation object
- Raises:
- Returns:
whether items were removed or not
- Return type:
Remove unlocked items which match the attributes from the secret service.
The attributes should be a set of key and value string pairs.
If self is
None
, then [func`Service`.get_sync] will be called to get the default [class`Service`] proxy.This method may block indefinitely and should not be used in user interface threads.
- create_item_dbus_path_sync(collection_path, properties, value, flags, cancellable)¶
- Parameters:
collection_path (
str
) – the D-Bus path of the collection in which to create itemproperties ({
str
:GLib.Variant
}) – hash table of D-Bus properties for the new collectionvalue (
Secret.Value
) – the secret value to store in the itemflags (
Secret.ItemCreateFlags
) – flags for the creation of the new itemcancellable (
Gio.Cancellable
orNone
) – optional cancellation object
- Raises:
- Returns:
a new string containing the D-Bus object path of the item
- Return type:
Create a new item in a secret service collection and return its D-Bus object path.
It is often easier to use [func`password_store_sync`] or [func`Item`.create_sync] rather than using this function. Using this method requires that you setup a correct hash table of D-Bus properties for the new collection.
If the flags contains
Secret.ItemCreateFlags.REPLACE
, then the secret service will search for an item matching the attributes, and update that item instead of creating a new one.properties is a set of properties for the new collection. The keys in the hash table should be interface.property strings like
org.freedesktop.Secret.Item.Label
. The values in the hash table should be [struct`GLib`.Variant] values of the properties.This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. [method`Service`.prompt] will be used to handle any prompts that are required.
- decode_dbus_secret(value)¶
- Parameters:
value (
GLib.Variant
) – the encoded secret- Returns:
the decoded secret value
- Return type:
Decode a [struct`Value`] into [struct`GLib`.Variant] received with the Secret Service DBus API.
The [struct`GLib`.Variant] should have a
(oayays)
signature.A session must have already been established by the [class`Service`], and the encoded secret must be valid for that session.
- encode_dbus_secret(value)¶
- Parameters:
value (
Secret.Value
) – the secret value- Returns:
the encoded secret
- Return type:
Encodes a [struct`Value`] into [struct`GLib`.Variant] for use with the Secret Service DBus API.
The resulting [struct`GLib`.Variant] will have a
(oayays)
signature.A session must have already been established by the [class`Service`].
- ensure_session(cancellable, callback, *user_data)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completesuser_data (
object
orNone
) – data to be passed to the callback
Ensure that the
Secret.Service
proxy has established a session with the Secret Service.This session is used to transfer secrets.
It is not normally necessary to call this method, as the session is established as necessary. You can also pass the
Secret.ServiceFlags.OPEN_SESSION
to [func`Service`.get] in order to ensure that a session has been established by the time you get theSecret.Service
proxy.This method will return immediately and complete asynchronously.
- ensure_session_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – the asynchronous result passed to the callback- Raises:
- Returns:
whether a session is established or not
- Return type:
Finish an asynchronous operation to ensure that the
Secret.Service
proxy has established a session with the Secret Service.
- ensure_session_sync(cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – optional cancellation object- Raises:
- Returns:
whether a session is established or not
- Return type:
Ensure that the
Secret.Service
proxy has established a session with the Secret Service.This session is used to transfer secrets.
It is not normally necessary to call this method, as the session is established as necessary. You can also pass the
Secret.ServiceFlags.OPEN_SESSION
to [func`Service`.get_sync] in order to ensure that a session has been established by the time you get theSecret.Service
proxy.This method may block indefinitely and should not be used in user interface threads.
- get_collection_gtype()¶
- Returns:
the gobject type for collections
- Return type:
Get the
GObject.Object
type for collections instantiated by this service.This will always be either [class`Collection`] or derived from it.
- get_collections()¶
- Returns:
a list of the collections in the secret service
- Return type:
[
Secret.Collection
] orNone
Get a list of [class`Collection`] objects representing all the collections in the secret service.
If the
Secret.ServiceFlags.LOAD_COLLECTIONS
flag was not specified when initializingSecret.Service
proxy object, then this method will returnNone
. Use [method`Service`.load_collections] to load the collections.
- get_flags()¶
- Returns:
the flags for features initialized
- Return type:
Get the flags representing what features of the
Secret.Service
proxy have been initialized.Use [method`Service`.ensure_session] or [method`Service`.load_collections] to initialize further features and change the flags.
- get_item_gtype()¶
- Returns:
the gobject type for items
- Return type:
Get the
GObject.Object
type for items instantiated by this service.This will always be either [class`Item`] or derived from it.
- get_session_algorithms()¶
-
Get the set of algorithms being used to transfer secrets between this secret service proxy and the Secret Service itself.
This will be
None
if no session has been established. Use [method`Service`.ensure_session] to establish a session.
- get_session_dbus_path()¶
-
Get the D-Bus object path of the session object being used to transfer secrets between this secret service proxy and the Secret Service itself.
This will be
None
if no session has been established. Use [method`Service`.ensure_session] to establish a session.
- load_collections(cancellable, callback, *user_data)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completesuser_data (
object
orNone
) – data to be passed to the callback
Ensure that the
Secret.Service
proxy has loaded all the collections present in the Secret Service.This affects the result of [method`Service`.get_collections].
You can also pass the
Secret.ServiceFlags.LOAD_COLLECTIONS
to [func`Service`.get_sync] in order to ensure that the collections have been loaded by the time you get theSecret.Service
proxy.This method will return immediately and complete asynchronously.
- load_collections_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – the asynchronous result passed to the callback- Raises:
- Returns:
whether the load was successful or not
- Return type:
Complete an asynchronous operation to ensure that the
Secret.Service
proxy has loaded all the collections present in the Secret Service.
- load_collections_sync(cancellable)¶
- Parameters:
cancellable (
Gio.Cancellable
orNone
) – optional cancellation object- Raises:
- Returns:
whether the load was successful or not
- Return type:
Ensure that the
Secret.Service
proxy has loaded all the collections present in the Secret Service.This affects the result of [method`Service`.get_collections].
You can also pass the
Secret.ServiceFlags.LOAD_COLLECTIONS
to [func`Service`.get_sync] in order to ensure that the collections have been loaded by the time you get theSecret.Service
proxy.This method may block indefinitely and should not be used in user interface threads.
- lock(objects, cancellable, callback, *user_data)¶
- Parameters:
objects ([
Gio.DBusProxy
]) – the items or collections to lockcancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completes
Lock items or collections in the secret service.
The secret service may not be able to lock items individually, and may lock an entire collection instead.
If self is
None
, then [func`Service`.get] will be called to get the default [class`Service`] proxy.This method returns immediately and completes asynchronously. The secret service may prompt the user. [method`Service`.prompt] will be used to handle any prompts that show up.
- lock_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – asynchronous result passed to the callback- Raises:
- Returns:
the number of items or collections that were locked
- locked:
location to place list of items or collections that were locked
- Return type:
(
int
, locked: [Gio.DBusProxy
])
Complete asynchronous operation to lock items or collections in the secret service.
The secret service may not be able to lock items individually, and may lock an entire collection instead.
- lock_sync(objects, cancellable)¶
- Parameters:
objects ([
Gio.DBusProxy
]) – the items or collections to lockcancellable (
Gio.Cancellable
orNone
) – optional cancellation object
- Raises:
- Returns:
the number of items or collections that were locked
- locked:
location to place list of items or collections that were locked
- Return type:
(
int
, locked: [Gio.DBusProxy
])
Lock items or collections in the secret service.
The secret service may not be able to lock items individually, and may lock an entire collection instead.
If self is
None
, then [func`Service`.get_sync] will be called to get the default [class`Service`] proxy.This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. [method`Service`.prompt] will be used to handle any prompts that show up.
- lookup(schema, attributes, cancellable, callback, *user_data)¶
- Parameters:
schema (
Secret.Schema
orNone
) – the schema for the attributescancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completesuser_data (
object
orNone
) – data to be passed to the callback
Lookup a secret value in the secret service.
The attributes should be a set of key and value string pairs.
If self is
None
, then [func`Service`.get] will be called to get the default [class`Service`] proxy.This method will return immediately and complete asynchronously.
- lookup_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – the asynchronous result passed to the callback- Raises:
- Returns:
a newly allocated [struct`Value`], which should be released with [method`Value`.unref], or
None
if no secret found- Return type:
Finish asynchronous operation to lookup a secret value in the secret service.
If no secret is found then
None
is returned.
- lookup_sync(schema, attributes, cancellable)¶
- Parameters:
schema (
Secret.Schema
orNone
) – the schema for the attributescancellable (
Gio.Cancellable
orNone
) – optional cancellation object
- Raises:
- Returns:
a newly allocated [struct`Value`], which should be released with [method`Value`.unref], or
None
if no secret found- Return type:
Lookup a secret value in the secret service.
The attributes should be a set of key and value string pairs.
If self is
None
, then [func`Service`.get_sync] will be called to get the default [class`Service`] proxy.This method may block indefinitely and should not be used in user interface threads.
- prompt(prompt, return_type, cancellable, callback, *user_data)¶
- Parameters:
prompt (
Secret.Prompt
) – the promptreturn_type (
GLib.VariantType
orNone
) – the variant type of the prompt resultcancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completesuser_data (
object
orNone
) – data to be passed to the callback
Perform prompting for a [class`Prompt`].
This function is called by other parts of this library to handle prompts for the various actions that can require prompting.
Override the
Secret.ServiceClass
[vfunc`Service`.prompt_async] virtual method to change the behavior of the prompting. The default behavior is to simply run [method`Prompt`.perform] on the prompt.
- prompt_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – the asynchronous result passed to the callback- Raises:
- Returns:
None
if the prompt was dismissed or an error occurred, a variant result if the prompt was successful- Return type:
Complete asynchronous operation to perform prompting for a [class`Prompt`].
Returns a variant result if the prompt was completed and not dismissed. The type of result depends on the action the prompt is completing, and is defined in the Secret Service DBus API specification.
- prompt_sync(prompt, cancellable, return_type)¶
- Parameters:
prompt (
Secret.Prompt
) – the promptcancellable (
Gio.Cancellable
orNone
) – optional cancellation objectreturn_type (
GLib.VariantType
) – the variant type of the prompt result
- Raises:
- Returns:
None
if the prompt was dismissed or an error occurred, a variant result if the prompt was successful- Return type:
Perform prompting for a [class`Prompt`].
Runs a prompt and performs the prompting. Returns a variant result if the prompt was completed and not dismissed. The type of result depends on the action the prompt is completing, and is defined in the Secret Service DBus API specification.
This function is called by other parts of this library to handle prompts for the various actions that can require prompting.
Override the
Secret.ServiceClass
[vfunc`Service`.prompt_sync] virtual method to change the behavior of the prompting. The default behavior is to simply run [method`Prompt`.perform_sync] on the prompt with aNone
window_id
.
- search(schema, attributes, flags, cancellable, callback, *user_data)¶
- Parameters:
schema (
Secret.Schema
orNone
) – the schema for the attributesattributes ({
str
:str
}) – search for items matching these attributesflags (
Secret.SearchFlags
) – search option flagscancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completes
Search for items matching the attributes.
All collections are searched. The attributes should be a table of string keys and string values.
If self is
None
, then [func`Service`.get] will be called to get the default [class`Service`] proxy.If
Secret.SearchFlags.ALL
is set in flags, then all the items matching the search will be returned. Otherwise only the first item will be returned. This is almost always the unlocked item that was most recently stored.If
Secret.SearchFlags.UNLOCK
is set in flags, then items will be unlocked if necessary. In either case, locked and unlocked items will match the search and be returned. If the unlock fails, the search does not fail.If
Secret.SearchFlags.LOAD_SECRETS
is set in flags, then the items will have their secret values loaded and available via [method`Item`.get_secret].This function returns immediately and completes asynchronously.
- search_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – asynchronous result passed to callback- Raises:
- Returns:
a list of items that matched the search
- Return type:
Complete asynchronous operation to search for items.
- search_sync(schema, attributes, flags, cancellable)¶
- Parameters:
schema (
Secret.Schema
orNone
) – the schema for the attributesattributes ({
str
:str
}) – search for items matching these attributesflags (
Secret.SearchFlags
) – search option flagscancellable (
Gio.Cancellable
orNone
) – optional cancellation object
- Raises:
- Returns:
a list of items that matched the search
- Return type:
Search for items matching the attributes.
All collections are searched. The attributes should be a table of string keys and string values.
If self is
None
, then [func`Service`.get_sync] will be called to get the default [class`Service`] proxy.If
Secret.SearchFlags.ALL
is set in flags, then all the items matching the search will be returned. Otherwise only the first item will be returned. This is almost always the unlocked item that was most recently stored.If
Secret.SearchFlags.UNLOCK
is set in flags, then items will be unlocked if necessary. In either case, locked and unlocked items will match the search and be returned. If the unlock fails, the search does not fail.If
Secret.SearchFlags.LOAD_SECRETS
is set in flags, then the items’ secret values will be loaded for any unlocked items. Loaded item secret values are available via [method`Item`.get_secret]. If the load of a secret values fail, then theThis function may block indefinitely. Use the asynchronous version in user interface threads.
- set_alias(alias, collection, cancellable, callback, *user_data)¶
- Parameters:
alias (
str
) – the alias to assign the collection tocollection (
Secret.Collection
orNone
) – the collection to assign to the aliascancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completes
Assign a collection to this alias.
Aliases help determine well known collections, such as ‘default’.
If self is
None
, then [func`Service`.get] will be called to get the default [class`Service`] proxy.This method will return immediately and complete asynchronously.
- set_alias_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – asynchronous result passed to callback- Raises:
- Returns:
True
if successful- Return type:
Finish an asynchronous operation to assign a collection to an alias.
- set_alias_sync(alias, collection, cancellable)¶
- Parameters:
alias (
str
) – the alias to assign the collection tocollection (
Secret.Collection
orNone
) – the collection to assign to the aliascancellable (
Gio.Cancellable
orNone
) – optional cancellation object
- Raises:
- Returns:
True
if successful- Return type:
Assign a collection to this alias. Aliases help determine well known collections, such as ‘default’.
If self is
None
, then [func`Service`.get_sync] will be called to get the default [class`Service`] proxy.This method may block and should not be used in user interface threads.
- store(schema, attributes, collection, label, value, cancellable, callback, *user_data)¶
- Parameters:
schema (
Secret.Schema
orNone
) – the schema to use to check attributescollection (
str
orNone
) – a collection alias, or D-Bus object path of the collection where to store the secretlabel (
str
) – label for the secretvalue (
Secret.Value
) – the secret valuecancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completesuser_data (
object
orNone
) – data to be passed to the callback
Store a secret value in the secret service.
The attributes should be a set of key and value string pairs.
If the attributes match a secret item already stored in the collection, then the item will be updated with these new values.
If self is
None
, then [func`Service`.get] will be called to get the default [class`Service`] proxy.If collection is not specified, then the default collection will be used. Use [constCOLLECTION_SESSION] to store the password in the session collection, which doesn’t get stored across login sessions.
This method will return immediately and complete asynchronously.
- store_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – the asynchronous result passed to the callback- Raises:
- Returns:
whether the storage was successful or not
- Return type:
Finish asynchronous operation to store a secret value in the secret service.
- store_sync(schema, attributes, collection, label, value, cancellable)¶
- Parameters:
schema (
Secret.Schema
orNone
) – the schema for the attributescollection (
str
orNone
) – a collection alias, or D-Bus object path of the collection where to store the secretlabel (
str
) – label for the secretvalue (
Secret.Value
) – the secret valuecancellable (
Gio.Cancellable
orNone
) – optional cancellation object
- Raises:
- Returns:
whether the storage was successful or not
- Return type:
Store a secret value in the secret service.
The attributes should be a set of key and value string pairs.
If the attributes match a secret item already stored in the collection, then the item will be updated with these new values.
If collection is
None
, then the default collection will be used. Use [constCOLLECTION_SESSION] to store the password in the session collection, which doesn’t get stored across login sessions.If self is
None
, then [func`Service`.get_sync] will be called to get the default [class`Service`] proxy.This method may block indefinitely and should not be used in user interface threads.
- unlock(objects, cancellable, callback, *user_data)¶
- Parameters:
objects ([
Gio.DBusProxy
]) – the items or collections to unlockcancellable (
Gio.Cancellable
orNone
) – optional cancellation objectcallback (
Gio.AsyncReadyCallback
orNone
) – called when the operation completes
Unlock items or collections in the secret service.
The secret service may not be able to unlock items individually, and may unlock an entire collection instead.
If self is
None
, then [func`Service`.get] will be called to get the default [class`Service`] proxy.This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. [method`Service`.prompt] will be used to handle any prompts that show up.
- unlock_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – asynchronous result passed to the callback- Raises:
- Returns:
the number of items or collections that were unlocked
- unlocked:
location to place list of items or collections that were unlocked
- Return type:
(
int
, unlocked: [Gio.DBusProxy
])
Complete asynchronous operation to unlock items or collections in the secret service.
The secret service may not be able to unlock items individually, and may unlock an entire collection instead.
- unlock_sync(objects, cancellable)¶
- Parameters:
objects ([
Gio.DBusProxy
]) – the items or collections to unlockcancellable (
Gio.Cancellable
orNone
) – optional cancellation object
- Raises:
- Returns:
the number of items or collections that were unlocked
- unlocked:
location to place list of items or collections that were unlocked
- Return type:
(
int
, unlocked: [Gio.DBusProxy
])
Unlock items or collections in the secret service.
The secret service may not be able to unlock items individually, and may unlock an entire collection instead.
If self is
None
, then [func`Service`.get_sync] will be called to get the default [class`Service`] proxy.This method may block indefinitely and should not be used in user interface threads. The secret service may prompt the user. [method`Service`.prompt] will be used to handle any prompts that show up.
- do_get_collection_gtype() virtual¶
- Returns:
the gobject type for collections
- Return type:
Get the
GObject.Object
type for collections instantiated by this service.This will always be either [class`Collection`] or derived from it.
- do_get_item_gtype() virtual¶
- Returns:
the gobject type for items
- Return type:
Get the
GObject.Object
type for items instantiated by this service.This will always be either [class`Item`] or derived from it.
- do_prompt_async(prompt, return_type, cancellable, callback, *user_data) virtual¶
- Parameters:
prompt (
Secret.Prompt
) –return_type (
GLib.VariantType
) –cancellable (
Gio.Cancellable
orNone
) –callback (
Gio.AsyncReadyCallback
orNone
) –
- do_prompt_finish(result) virtual¶
- Parameters:
result (
Gio.AsyncResult
) – the asynchronous result passed to the callback- Returns:
None
if the prompt was dismissed or an error occurred, a variant result if the prompt was successful- Return type:
Complete asynchronous operation to perform prompting for a [class`Prompt`].
Returns a variant result if the prompt was completed and not dismissed. The type of result depends on the action the prompt is completing, and is defined in the Secret Service DBus API specification.
- do_prompt_sync(prompt, cancellable, return_type) virtual¶
- Parameters:
prompt (
Secret.Prompt
) – the promptcancellable (
Gio.Cancellable
orNone
) – optional cancellation objectreturn_type (
GLib.VariantType
) – the variant type of the prompt result
- Returns:
None
if the prompt was dismissed or an error occurred, a variant result if the prompt was successful- Return type:
Perform prompting for a [class`Prompt`].
Runs a prompt and performs the prompting. Returns a variant result if the prompt was completed and not dismissed. The type of result depends on the action the prompt is completing, and is defined in the Secret Service DBus API specification.
This function is called by other parts of this library to handle prompts for the various actions that can require prompting.
Override the
Secret.ServiceClass
[vfunc`Service`.prompt_sync] virtual method to change the behavior of the prompting. The default behavior is to simply run [method`Prompt`.perform_sync] on the prompt with aNone
window_id
.