Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt HTTP authentication with QNetworkAccessManager

I'm working with a webservice which requires a valid username/password. From PyQt, I'm accessing the webservice using QNetworkAccessManager which emits the

authenticationRequired (QNetworkReply*, QAuthenticator*)

signal when (obviously), authentication is required. When I fill in the user and psswd for QAuthenticator, everything works fine. However, I can't see how to break the loop when the user is not valid.

From the docs for authenticationRequired:

"If it rejects the credentials, this signal will be emitted again."

For invalid credentials this signal is emitted again, and again, and again... Looking at the error code in the reply showed 0. How is this loop supposed to be broken or handled so that it terminates with an error?

like image 219
brianz Avatar asked Aug 31 '25 10:08

brianz


1 Answers

Yeh, it's odd. What I've done previously is check if I've already authenticated with those details and if I have then call QNetworkReply.abort()

like image 88
Mike McQuaid Avatar answered Sep 02 '25 23:09

Mike McQuaid