Class: QgsAuthMethodConfig

Configuration storage class for authentication method configurations.

Methods

clearConfigMap

Clear all configs

config

Returns a config's value

configList

Returns a config's list of values

configMap

Gets extended configuration, mapped to key/value pairs of QStrings

configString

The extended configuration, as stored and retrieved from the authentication database

hasConfig

Whether a config key exists in config map

id

Gets 'authcfg' 7-character alphanumeric ID of the config

isValid

Whether the configuration is valid

loadConfigString

Load existing extended configuration

method

Textual key of the associated authentication method

name

Gets name of configuration

readXml

from a DOM element.

removeConfig

Remove a config from map

setConfig

Set a single config value per key in the map

setConfigList

Set a multiple config values per key in the map

setConfigMap

Set extended configuration map

setId

Sets auth config ID

setMethod

setName

Sets name of configuration

setUri

setVersion

Sets version of the configuration

uri

A URI to auto-select a config when connecting to a resource

version

Gets version of the configuration

writeXml

Stores the configuration in a DOM

Static Methods

uriToResource

A utility function for generating a resource from a URL to be compared against the config's uri() for auto-selecting authentication configs to use

class qgis.core.QgsAuthMethodConfig[source]

Bases: object

__init__(method: str | None = '', version: int = 0)

Construct a configuration for an authentication method

Parameters:
  • method (Optional[str] = '') – Textual key of the authentication method

  • version (int = 0) – Version of the configuration (for updating previously saved configs later on)

__init__(a0: QgsAuthMethodConfig)
Parameters:

a0 (QgsAuthMethodConfig)

clearConfigMap(self)[source]

Clear all configs

config(self, key: str | None, defaultvalue: str | None = '') str[source]

Returns a config’s value

Parameters:
  • key (Optional[str]) – Config key

  • defaultvalue (Optional[str] = '') – Default value, if key not found

Return type:

str

configList(self, key: str | None) List[str][source]

Returns a config’s list of values

Parameters:

key (Optional[str])

Return type:

List[str]

configMap(self) Dict[str, str][source]

Gets extended configuration, mapped to key/value pairs of QStrings

Return type:

Dict[str, str]

configString(self) str[source]

The extended configuration, as stored and retrieved from the authentication database

Note

This is an internal construct used by QgsAuthManager that should generally not be set by client code

Return type:

str

hasConfig(self, key: str | None) bool[source]

Whether a config key exists in config map

Parameters:

key (Optional[str])

Return type:

bool

id(self) str[source]

Gets ‘authcfg’ 7-character alphanumeric ID of the config

Note

This is set by QgsAuthManager when the config is initially stored

Return type:

str

isValid(self, validateid: bool = False) bool[source]

Whether the configuration is valid

Parameters:

validateid (bool = False) – Additionally verify the auth config ID is not empty

Return type:

bool

loadConfigString(self, configstr: str | None)[source]

Load existing extended configuration

Parameters:

configstr (Optional[str]) – Configuration string to load

method(self) str[source]

Textual key of the associated authentication method

Return type:

str

name(self) str[source]

Gets name of configuration

Return type:

str

readXml(self, element: QDomElement) bool[source]

from a DOM element.

Parameters:

element (QDomElement) – is the DOM node corresponding to item (e.g. ‘LayoutItem’ element)

Added in version 3.20.

Return type:

bool

removeConfig(self, key: str | None) int[source]

Remove a config from map

Parameters:

key (Optional[str]) – Config to remove

Return type:

int

Returns:

Number of keys removed (should always be 1 or 0)

setConfig(self, key: str | None, value: str | None)[source]

Set a single config value per key in the map

Note

if key exists, it is replaced

Parameters:
  • key (Optional[str]) – Config key

  • value (Optional[str]) – Config value

setConfigList(self, key: str | None, value: Iterable[str | None])[source]

Set a multiple config values per key in the map

Note

if key exists, it is replaced

Parameters:
  • key (Optional[str]) – Config key

  • value (Iterable[Optional[str]]) – Config value

setConfigMap(self, map: Dict[str | None, str | None])[source]

Set extended configuration map

Parameters:

map (Dict[Optional[str], Optional[str]]) – Map to set

setId(self, id: str | None)[source]

Sets auth config ID

Parameters:

id (Optional[str])

setMethod(self, method: str | None)[source]
Parameters:

method (Optional[str])

setName(self, name: str | None)[source]

Sets name of configuration

Parameters:

name (Optional[str])

setUri(self, uri: str | None)[source]
Parameters:

uri (Optional[str])

setVersion(self, version: int)[source]

Sets version of the configuration

Parameters:

version (int)

uri(self) str[source]

A URI to auto-select a config when connecting to a resource

Return type:

str

static uriToResource(accessurl: str | None, resource: str | None | None, withpath: bool = False) bool[source]

A utility function for generating a resource from a URL to be compared against the config’s uri() for auto-selecting authentication configs to use

Note

Essentially strips the URL query variables, and by default, strips the path as well

Parameters:
  • accessurl (Optional[str]) – A URL to process

  • resource (Optional[Optional[str]]) – Output variable for result

  • withpath (bool = False) – Whether to include the URI’s path in output

Return type:

bool

version(self) int[source]

Gets version of the configuration

Return type:

int

writeXml(self, parentElement: QDomElement, document: QDomDocument) bool[source]

Stores the configuration in a DOM

Parameters:
  • parentElement (QDomElement) – parent DOM element

  • document (QDomDocument) – DOM document

See also

readXml()

Added in version 3.20.

Return type:

bool