AuthenticationRequest

class AuthenticationRequest(**properties: Any)

Superclasses: Object

Represents an authentication request.

Whenever a client attempts to load a page protected by HTTP authentication, credentials will need to be provided to authorize access. To allow the client to decide how it wishes to handle authentication, WebKit will fire a WebView::authenticate signal with a WebKitAuthenticationRequest object to provide client side authentication support. Credentials are exposed through the Credential object.

In case the client application does not wish to handle this signal WebKit will provide a default handler. To handle authentication asynchronously, simply increase the reference count of the WebKitAuthenticationRequest object.

Methods

class AuthenticationRequest
authenticate(credential: Credential | None = None) None

Authenticate the AuthenticationRequest.

Authenticate the AuthenticationRequest using the Credential supplied. To continue without credentials, pass None as credential.

Added in version 2.2.

Parameters:

credential – A Credential, or None

can_save_credentials() bool

Determine whether this AuthenticationRequest should allow the storage of credentials.

Determine whether the authentication method associated with this AuthenticationRequest should allow the storage of credentials. This will return False if WebKit doesn’t support credential storing, if private browsing is enabled, or if persistent credential storage has been disabled in WebsiteDataManager, unless credentials saving has been explicitly enabled with set_can_save_credentials().

Added in version 2.2.

cancel() None

Cancel the authentication challenge.

This will also cancel the page loading and result in a WebView::load-failed signal with a WebKitNetworkError of type CANCELLED being emitted.

Added in version 2.2.

get_certificate_pin_flags() TlsPasswordFlags

Get the TlsPasswordFlags of the CLIENT_CERTIFICATE_PIN_REQUESTED authentication challenge.

Added in version 2.34.

get_host() str

Get the host that this authentication challenge is applicable to.

Added in version 2.2.

get_port() int

Get the port that this authentication challenge is applicable to.

Added in version 2.2.

get_proposed_credential() Credential

Get the Credential of the proposed authentication challenge.

Get the Credential of the proposed authentication challenge that was stored from a previous session. The client can use this directly for authentication or construct their own Credential.

Added in version 2.2.

get_realm() str

Get the realm that this authentication challenge is applicable to.

Added in version 2.2.

get_scheme() AuthenticationScheme

Get the authentication scheme of the authentication challenge.

Added in version 2.2.

get_security_origin() SecurityOrigin

Get the SecurityOrigin that this authentication challenge is applicable to.

Added in version 2.30.

is_for_proxy() bool

Determine whether the authentication challenge is associated with a proxy server.

Determine whether the authentication challenge is associated with a proxy server rather than an “origin” server.

Added in version 2.2.

is_retry() bool

Determine whether this this is a first attempt or a retry for this authentication challenge.

Added in version 2.2.

set_can_save_credentials(enabled: bool) None

Set whether the authentication method associated with request should allow the storage of credentials.

Set whether the authentication method associated with request should allow the storage of credentials. This should be used by applications handling their own credentials storage to indicate that it should be supported even when internal credential storage is disabled or unsupported. Note that storing of credentials will not be allowed on ephemeral sessions in any case.

Added in version 2.30.

Parameters:

enabled – value to set

set_proposed_credential(credential: Credential) None

Set the Credential of the proposed authentication challenge.

Set the Credential of the proposed authentication challenge that was stored from a previous session. This should only be used by applications handling their own credential storage. (When using the default WebKit credential storage, get_proposed_credential() already contains previously-stored credentials.) Passing a None credential will clear the proposed credential.

Added in version 2.30.

Parameters:

credential – a Credential, or None

Signals

class AuthenticationRequest.signals
authenticated(credential: Credential) None

This signal is emitted when the user authentication request succeeded. Applications handling their own credential storage should connect to this signal to save the credentials.

Added in version 2.30.

Parameters:

credential – the Credential accepted

cancelled() None

This signal is emitted when the user authentication request is cancelled. It allows the application to dismiss its authentication dialog in case of page load failure for example.

Added in version 2.2.