QGIS API Documentation 3.27.0-Master (1c05421486)
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. More...
 
virtual void handleAuthRequestCloseBrowser ()
 Called to terminate a network authentication through external browser. More...
 
virtual void handleAuthRequestOpenBrowser (const QUrl &url)
 Called to initiate a network authentication through external browser url. More...
 

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 217 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 876 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 888 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 882 of file qgsnetworkaccessmanager.cpp.


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