Secret.Item

g GObject.GInterface GObject.GInterface Gio.AsyncInitable Gio.AsyncInitable GObject.GInterface->Gio.AsyncInitable Gio.DBusInterface Gio.DBusInterface GObject.GInterface->Gio.DBusInterface Gio.Initable Gio.Initable GObject.GInterface->Gio.Initable Secret.Retrievable Secret.Retrievable GObject.GInterface->Secret.Retrievable GObject.Object GObject.Object Gio.DBusProxy Gio.DBusProxy GObject.Object->Gio.DBusProxy Gio.AsyncInitable->Gio.DBusProxy Gio.DBusInterface->Gio.DBusProxy Secret.Item Secret.Item Gio.DBusProxy->Secret.Item Gio.Initable->Gio.DBusProxy Secret.Retrievable->Secret.Item

Subclasses:

None

Methods

Inherited:

Gio.DBusProxy (25), GObject.Object (37), Gio.AsyncInitable (4), Gio.DBusInterface (3), Gio.Initable (2), Secret.Retrievable (7)

Structs:

GObject.ObjectClass (5)

class

create (collection, schema, attributes, label, value, flags, cancellable, callback, *user_data)

class

create_finish (result)

class

create_sync (collection, schema, attributes, label, value, flags, cancellable)

class

load_secrets (items, cancellable, callback, *user_data)

class

load_secrets_finish (result)

class

load_secrets_sync (items, cancellable)

delete (cancellable, callback, *user_data)

delete_finish (result)

delete_sync (cancellable)

get_attributes ()

get_created ()

get_flags ()

get_label ()

get_locked ()

get_modified ()

get_schema_name ()

get_secret ()

get_service ()

load_secret (cancellable, callback, *user_data)

load_secret_finish (result)

load_secret_sync (cancellable)

refresh ()

set_attributes (schema, attributes, cancellable, callback, *user_data)

set_attributes_finish (result)

set_attributes_sync (schema, attributes, cancellable)

set_label (label, cancellable, callback, *user_data)

set_label_finish (result)

set_label_sync (label, cancellable)

set_secret (value, cancellable, callback, *user_data)

set_secret_finish (result)

set_secret_sync (value, cancellable)

Virtual Methods

Inherited:

Gio.DBusProxy (2), GObject.Object (7), Gio.AsyncInitable (2), Gio.DBusInterface (3), Gio.Initable (1), Secret.Retrievable (2)

Properties

Inherited:

Gio.DBusProxy (9), Secret.Retrievable (4)

Name

Type

Flags

Short Description

flags

Secret.ItemFlags

r/w/co

Item flags

locked

bool

r

Item locked

service

Secret.Service

r/w/co

Secret Service

Signals

Inherited:

Gio.DBusProxy (2), GObject.Object (1)

Fields

Inherited:

Gio.DBusProxy (2), GObject.Object (1)

Name

Type

Access

Description

parent_instance

Gio.DBusProxy

r

Class Details

class Secret.Item(**kwargs)
Bases:

Gio.DBusProxy, Secret.Retrievable

Abstract:

No

Structure:

Secret.ItemClass

A secret item

Secret.Item represents a secret item stored in the Secret Service.

Each item has a value, represented by a [struct`Value`], which can be retrieved by [method`Item`.get_secret] or set by [method`Item`.set_secret]. The item is only available when the item is not locked.

Items can be locked or unlocked using the [method`Service`.lock] or [method`Service`.unlock] functions. The Secret Service may not be able to unlock individual items, and may unlock an entire collection when a single item is unlocked.

Each item has a set of attributes, which are used to locate the item later. These are not stored or transferred in a secure manner. Each attribute has a string name and a string value. Use [method`Service`.search] to search for items based on their attributes, and [method`Item`.set_attributes] to change the attributes associated with an item.

Items can be created with [func`Item`.create] or [method`Service`.store].

classmethod create(collection, schema, attributes, label, value, flags, cancellable, callback, *user_data)
Parameters:

Create a new item in the secret service.

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.

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.

classmethod create_finish(result)
Parameters:

result (Gio.AsyncResult) – the asynchronous result passed to the callback

Raises:

GLib.Error

Returns:

the new item, which should be unreferenced with [method`GObject`.Object.unref]

Return type:

Secret.Item

Finish operation to create a new item in the secret service.

classmethod create_sync(collection, schema, attributes, label, value, flags, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

the new item, which should be unreferenced with [method`GObject`.Object.unref]

Return type:

Secret.Item

Create a new item in the secret service.

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.

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.

classmethod load_secrets(items, cancellable, callback, *user_data)
Parameters:

Load the secret values for a secret item stored in the service.

The items must all have the same [property`Item`:py:data::service<Secret.Item.props.service>] property.

This function returns immediately and completes asynchronously.

classmethod load_secrets_finish(result)
Parameters:

result (Gio.AsyncResult) – asynchronous result passed to callback

Raises:

GLib.Error

Returns:

whether the operation succeeded or not

Return type:

bool

Complete asynchronous operation to load the secret values for secret items stored in the service.

Items that are locked will not have their secrets loaded.

classmethod load_secrets_sync(items, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

whether the operation succeeded or not

Return type:

bool

Load the secret values for a secret item stored in the service.

The items must all have the same [property`Item`:py:data::service<Secret.Item.props.service>] property.

This method may block indefinitely and should not be used in user interface threads.

Items that are locked will not have their secrets loaded.

delete(cancellable, callback, *user_data)
Parameters:

Delete this item.

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.

delete_finish(result)
Parameters:

result (Gio.AsyncResult) – asynchronous result passed to the callback

Raises:

GLib.Error

Returns:

whether the item was successfully deleted or not

Return type:

bool

Complete asynchronous operation to delete the secret item.

delete_sync(cancellable)
Parameters:

cancellable (Gio.Cancellable or None) – optional cancellation object

Raises:

GLib.Error

Returns:

whether the item was successfully deleted or not

Return type:

bool

Delete this secret item.

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.

get_attributes()
Returns:

a new reference to the attributes, which should not be modified, and released with [func`GLib`.HashTable.unref]

Return type:

{str: str}

Set the attributes of this item.

The attributes are a mapping of string keys to string values. Attributes are used to search for items. Attributes are not stored or transferred securely by the secret service.

Do not modify the attributes returned by this method. Use [method`Item`.set_attributes] instead.

get_created()
Returns:

the created date and time

Return type:

int

Get the created date and time of the item.

The return value is the number of seconds since the unix epoch, January 1st 1970.

get_flags()
Returns:

the flags for features initialized

Return type:

Secret.ItemFlags

Get the flags representing what features of the Secret.Item proxy have been initialized.

Use [method`Item`.load_secret] to initialize further features and change the flags.

get_label()
Returns:

the label, which should be freed with [func`GLib`.free]

Return type:

str

Get the label of this item.

get_locked()
Returns:

whether the item is locked or not

Return type:

bool

Get whether the item is locked or not.

Depending on the secret service an item may not be able to be locked independently from the collection that it is in.

get_modified()
Returns:

the modified date and time

Return type:

int

Get the modified date and time of the item.

The return value is the number of seconds since the unix epoch, January 1st 1970.

get_schema_name()
Returns:

the schema name

Return type:

str or None

Gets the name of the schema that this item was stored with. This is also available at the xdg:schema attribute.

get_secret()
Returns:

the secret value which should be released with [method`Value`.unref], or None

Return type:

Secret.Value or None

Get the secret value of this item.

If this item is locked or the secret has not yet been loaded then this will return None.

To load the secret call the [method`Item`.load_secret] method.

get_service()
Returns:

the Secret Service object

Return type:

Secret.Service

Get the Secret Service object that this item was created with.

load_secret(cancellable, callback, *user_data)
Parameters:

Load the secret value of this item.

Each item has a single secret which might be a password or some other secret binary value.

This function will fail if the secret item is locked.

This function returns immediately and completes asynchronously.

load_secret_finish(result)
Parameters:

result (Gio.AsyncResult) – asynchronous result passed to callback

Raises:

GLib.Error

Returns:

whether the secret item successfully loaded or not

Return type:

bool

Complete asynchronous operation to load the secret value of this item.

The newly loaded secret value can be accessed by calling [method`Item`.get_secret].

load_secret_sync(cancellable)
Parameters:

cancellable (Gio.Cancellable or None) – optional cancellation object

Raises:

GLib.Error

Returns:

whether the secret item successfully loaded or not

Return type:

bool

Load the secret value of this item.

Each item has a single secret which might be a password or some other secret binary value.

This function may block indefinitely. Use the asynchronous version in user interface threads.

refresh()

Refresh the properties on this item.

This fires off a request to refresh, and the properties will be updated later.

Calling this method is not normally necessary, as the secret service will notify the client when properties change.

set_attributes(schema, attributes, cancellable, callback, *user_data)
Parameters:

Set the attributes of this item.

The attributes are a mapping of string keys to string values. Attributes are used to search for items. Attributes are not stored or transferred securely by the secret service.

This function returns immediately and completes asynchronously.

set_attributes_finish(result)
Parameters:

result (Gio.AsyncResult) – asynchronous result passed to the callback

Raises:

GLib.Error

Returns:

whether the change was successful or not

Return type:

bool

Complete operation to set the attributes of this item.

set_attributes_sync(schema, attributes, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

whether the change was successful or not

Return type:

bool

Set the attributes of this item.

The attributes are a mapping of string keys to string values. Attributes are used to search for items. Attributes are not stored or transferred securely by the secret service.

This function may block indefinitely. Use the asynchronous version in user interface threads.

set_label(label, cancellable, callback, *user_data)
Parameters:

Set the label of this item.

This function returns immediately and completes asynchronously.

set_label_finish(result)
Parameters:

result (Gio.AsyncResult) – asynchronous result passed to callback

Raises:

GLib.Error

Returns:

whether the change was successful or not

Return type:

bool

Complete asynchronous operation to set the label of this collection.

set_label_sync(label, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

whether the change was successful or not

Return type:

bool

Set the label of this item.

This function may block indefinitely. Use the asynchronous version in user interface threads.

set_secret(value, cancellable, callback, *user_data)
Parameters:

Set the secret value of this item.

Each item has a single secret which might be a password or some other secret binary value.

This function returns immediately and completes asynchronously.

set_secret_finish(result)
Parameters:

result (Gio.AsyncResult) – asynchronous result passed to callback

Raises:

GLib.Error

Returns:

whether the change was successful or not

Return type:

bool

Complete asynchronous operation to set the secret value of this item.

set_secret_sync(value, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

whether the change was successful or not

Return type:

bool

Set the secret value of this item.

Each item has a single secret which might be a password or some other secret binary value.

This function may block indefinitely. Use the asynchronous version in user interface threads.

Property Details

Secret.Item.props.flags
Name:

flags

Type:

Secret.ItemFlags

Default Value:

Secret.ItemFlags.NONE

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

A set of flags describing which parts of the secret item have been initialized.

Secret.Item.props.locked
Name:

locked

Type:

bool

Default Value:

True

Flags:

READABLE

Whether the item is locked or not.

An item may not be independently lockable separate from other items in its collection.

To lock or unlock a item use the [method`Service`.lock] or [method`Service`.unlock] functions.

Secret.Item.props.service
Name:

service

Type:

Secret.Service

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The [class`Service`] object that this item is associated with and uses to interact with the actual D-Bus Secret Service.