qtqnetworkaccessmanager

Basic authentication with Qt (QNetworkAccessManager)


I was trying to perform basic authentication for Twitter from my Qt app. I use QNetworkAccessManager. But I couldn't find any help on this.

But I found a program called qsoapmanager which passes credentials in base64 through the header. Maybe I can do this with QNAM by setting header in QNetowrkRequest. But I failed to find a way.

In qsoapman source, header is set like this:

QHttpRequestHeader header;

header.setValue( "Authorization", QString( "Basic " ).append( auth.data() ) );

Can I do just that with QNAM/QNReq or is there a better way?


Solution

  • The recommended way is to connect to the authenticationRequired signal and set the credentials from there.