I am using QOAuth2AuthorizationCodeFlow to perform OIDC authentication. I can connect to the signal QAbstractOAuth::granted() and be notified when it worked with success. Fine.
My problem is: how to be notified when something wrong happened?
I tried to connect to the QAbstractOAuth2::error() signal but I am not notified. I used:
QObject::connect(this, SIGNAL(error(const QString &, const QString &, const QUrl &)), this, SLOT(catchAll()));
In the application console I see the error reported by the server:
qt.networkauth.replyhandler: Error transferring https://idp.safenetid.com/auth/realms/2H31DFOIEQ-STA/protocol/openid-connect/token - server replied: Fake Bad request
So Qt detected the problem. It looks like the probem is detected in QHttpThreadDelegate::finishedSlot():
if (httpReply->statusCode() >= 400) {
// it's an error reply
QString msg = QLatin1String(QT_TRANSLATE_NOOP("QNetworkReply",
"Error transferring %1 - server replied: %2"));
msg = msg.arg(httpRequest.url().toString(), httpReply->reasonPhrase());
emit error(statusCodeFromHttp(httpReply->statusCode(), httpRequest.url()), msg);
}
An error() signal is emitted. But it is catched by Qt itself and not reported upstream to the application?
Note: Sometimes the server I use replies with an HTTP error code 400 and message "User not found". Here I faked the problem using mitmproxy to be able to reproduce the issue easily.
PS: I think it is a missing feature in Qt. So I created an issue for QOAuth2AuthorizationCodeFlow::requestAccessToken() at https://bugreports.qt.io/browse/QTBUG-102279