It depends on how the server is demanding a username and password.
If you try to fetch a page and get an HTTP response code 401 Unauthorized (possibly shows as QNetworkReply::ContentAccessDenied in your error handling slot) then you can probably just use QUrl::setUserName() and QUrl::setPassword() before you create and send your QNetworkRequest.
If you mean the server sends you to a separate HTML page that has a form requesting user name and password then you need to make two separate requests in sequence:
- An HTTP POST (or, less likely, GET) to the form's submit URL with encoded data to mimic submitting the authentication form. You will need to arrange keeping any cookies the server sends in the response.
- An HTTP GET to fetch the resource you wanted.




Reply With Quote

Bookmarks