Class: QgsAuthMethodConfig

class qgis.core.QgsAuthMethodConfig

Bases: sip.wrapper

Configuration storage class for authentication method configurations

QgsAuthMethodConfig(method: str = ‘’, version: int = 0) Construct a configuration for an authentication method

Parameters
  • method – Textual key of the authentication method

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

QgsAuthMethodConfig(QgsAuthMethodConfig)

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

param method

setName

Sets name of configuration

setUri

param uri

setVersion

Sets version of the configuration

uri

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

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

version

Gets version of the configuration

writeXml

Stores the configuration in a DOM

clearConfigMap(self)

Clear all configs

config(self, key: str, defaultvalue: str = '') str

Returns a config’s value

Parameters
  • key (str) – Config key

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

Return type

str

configList(self, key: str) List[str]

Returns a config’s list of values

Parameters

key (str) –

Return type

List[str]

configMap(self) Dict[str, str]

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

Return type

Dict[str, str]

configString(self) str

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) bool

Whether a config key exists in config map

Parameters

key (str) –

Return type

bool

id(self) str

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

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)

Load existing extended configuration

Parameters

configstr (str) – Configuration string to load

method(self) str

Textual key of the associated authentication method

Return type

str

name(self) str

Gets name of configuration

Return type

str

readXml(self, element: QDomElement) bool

from a DOM element.

Parameters

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

New in version 3.20.

Return type

bool

removeConfig(self, key: str) int

Remove a config from map

Parameters

key (str) – Config to remove

Return type

int

Returns

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

setConfig(self, key: str, value: str)

Set a single config value per key in the map

Note

if key exists, it is replaced

Parameters
  • key (str) – Config key

  • value (str) – Config value

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

Set a multiple config values per key in the map

Note

if key exists, it is replaced

Parameters
  • key (str) – Config key

  • value (Iterable[str]) – Config value

setConfigMap(self, map: Dict[str, str])

Set extended configuration map

Parameters

map (Dict[str) – Map to set

setId(self, id: str)

Sets auth config ID

Parameters

id (str) –

setMethod(self, method: str)
Parameters

method (str) –

setName(self, name: str)

Sets name of configuration

Parameters

name (str) –

setUri(self, uri: str)
Parameters

uri (str) –

setVersion(self, version: int)

Sets version of the configuration

Parameters

version (int) –

uri(self) str

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

Return type

str

uriToResource(accessurl: str, resource: str, withpath: bool = False) bool

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 (str) – A URL to process

  • resource (str) – Output variable for result

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

Return type

bool

version(self) int

Gets version of the configuration

Return type

int

writeXml(self, parentElement: QDomElement, document: QDomDocument) bool

Stores the configuration in a DOM

Parameters
  • parentElement (QDomElement) – parent DOM element

  • document (QDomDocument) – DOM document

See also

readXml()

New in version 3.20.

Return type

bool