QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsNetworkAuthenticationHandler Class Reference

Network authentication handler, used for responding to network authentication requests during network requests. More...

#include <qgsnetworkaccessmanager.h>

Public Member Functions

virtual ~QgsNetworkAuthenticationHandler ()=default
 
virtual void handleAuthRequest (QNetworkReply *reply, QAuthenticator *auth)
 Called whenever network authentication requests are encountered during a network reply.
 
virtual void handleAuthRequestCloseBrowser ()
 Called to terminate a network authentication through external browser.
 
virtual void handleAuthRequestOpenBrowser (const QUrl &url)
 Called to initiate a network authentication through external browser url.
 

Detailed Description

Network authentication handler, used for responding to network authentication requests during network requests.

QgsNetworkAuthenticationHandler responds to authentication requests encountered during network requests. The base QgsNetworkAuthenticationHandler class responds to requests only by logging the request, but does not provide any username or password to allow the request to proceed.

Subclasses can override this behavior by implementing their own handleAuthRequest() method. QgsNetworkAuthenticationHandler are ONLY ever called from the main thread, so it is safe to utilize gui widgets and dialogs during handleAuthRequest (e.g. to present prompts to users requesting the username and password).

If a reply is coming from background thread, that thread is blocked while handleAuthRequest() is running.

An application instance can only have a single network authentication handler. The current authentication handler is set by calling QgsNetworkAccessManager::setAuthHandler(). By default an instance of the logging-only QgsNetworkAuthenticationHandler base class is used.

Since
QGIS 3.6

Definition at line 206 of file qgsnetworkaccessmanager.h.

Constructor & Destructor Documentation

◆ ~QgsNetworkAuthenticationHandler()

virtual QgsNetworkAuthenticationHandler::~QgsNetworkAuthenticationHandler ( )
virtualdefault

Member Function Documentation

◆ handleAuthRequest()

void QgsNetworkAuthenticationHandler::handleAuthRequest ( QNetworkReply *  reply,
QAuthenticator *  auth 
)
virtual

Called whenever network authentication requests are encountered during a network reply.

Subclasses should reimplement this method to implement their own logic regarding how to handle the requests and whether they should be presented to users.

The base class method just logs the request but does not provide any username/password resolution.

Definition at line 884 of file qgsnetworkaccessmanager.cpp.

◆ handleAuthRequestCloseBrowser()

void QgsNetworkAuthenticationHandler::handleAuthRequestCloseBrowser ( )
virtual

Called to terminate a network authentication through external browser.

Since
QGIS 3.20

Definition at line 896 of file qgsnetworkaccessmanager.cpp.

◆ handleAuthRequestOpenBrowser()

void QgsNetworkAuthenticationHandler::handleAuthRequestOpenBrowser ( const QUrl &  url)
virtual

Called to initiate a network authentication through external browser url.

Since
QGIS 3.20

Definition at line 890 of file qgsnetworkaccessmanager.cpp.


The documentation for this class was generated from the following files: