PDA

View Full Version : Url request problem for https: Host requires authentication



roseicollis
10th March 2015, 16:54
Hi,

I'm using Qt 4.8.5. I was making a request to an url which gaves me back a json reply. It was all ok until I had to change the url from http:// to https:// (Note the security 's' )



text = "https://myweb.com/api/mylist?PARAM1=00000000&PARAM2=1111111111&PARAM3=2222222";
_Url = text;

QNetworkRequest request(_Url);
QNetworkReply *myReply = nam->get(request);


Now if you do a reply->ErrorString() you get: "Host requires authentication"

How can I fix that problem? Any example or idea?

Thanks a lot!

anda_skoa
10th March 2015, 17:46
Have you tried connecting to the network manager's authenticationRequired() signal?

Cheers,
_

roseicollis
11th March 2015, 09:47
Hi anda_skoa, I tried with:



m_ftpManagerPtr = new QNetworkAccessManager(this);
connect ( m_ftpManagerPtr, SIGNAL(authenticationRequired(QNetworkReply*,QAuth enticator*)), this, SLOT(onAuthenticationRequestSlot(QNetworkReply*,QA uthenticator*)) );

void Test::onAuthenticationRequestSlot(QNetworkReply *aReply, QAuthenticator *aAuthenticator)
{
aAuthenticator->setUser(m_ftpUser);
aAuthenticator->setPassword(m_ftpPasswd);
}


But it don't gets into the slot, do you know why? do I have to initialize something before?

anda_skoa
11th March 2015, 11:56
Hmm.
Did the connect succeed? I.e. is its return value "true"?

Cheers,
_