Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QNetworkReply::ContentAccessDenied

QNetworkReply::ContentAccessDenied

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 2.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MarlonBM
    wrote on last edited by
    #1

    Hi, i just know a little english. this is my issue.
    I want to login and I'am using QNetworkAccessManager to connect to web that use https.

    this is my code

    QUrlQuery query;
    query.addQueryItem("user", user->getEmail());
    query.addQueryItem("pass", user->getPass());

    QString strQuery = query.query(QUrl::FullyEncoded);
    QByteArray post = strQuery.toUtf8();

    // Create request and attach ssl configuration to it
    QNetworkRequest request;
    request.setUrl(QUrl("https://myurl/login"));

    request.setHeader(QNetworkRequest::ContentTypeHeader, "text/html; charset=UTF-8");
    request.setHeader(QNetworkRequest::UserAgentHeader, "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0");
    request.setRawHeader("Accept-Encoding","gzip, deflate");
    QSslConfiguration sslConfiguration = QSslConfiguration::defaultConfiguration();
    request.setSslConfiguration(sslConfiguration);

    QNetworkReply *reply = manager->post(request, post);

    but the system always send me this error
    QNetworkReply::ContentAccessDenied
    statusCode: 403 statusName:"Forbidden"

    But when i use the browse and put directly this url:
    https://myurl/login?user=user1&pass=pass1

    works and the user can login

    what i'am doing wrong in my code?

    1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by Kent-Dorfman
      #2

      what happens if you hardcode the string literals for user and pass into the query.addQueryItem("user", "lteral"); calls?

      Also, HTTP protocol requires <CR><LF> liner terminators, IIRC. Have you verified the format of the headers you are sending?

      If you meet the AI on the road, kill it.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MarlonBM
        wrote on last edited by
        #3

        I'am using http header live of mozilla, this is the respond

        User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0

        Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8

        Accept-Language: es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3

        Accept-Encoding: gzip, deflate, br

        Connection: keep-alive

        Cookie: __cfduid=d74b1e92b11332b88ec011ff9d4175f1d1553622050; _ga=GA1.3.837904067.1553622282; _pk_id.2.170d=160538fce0b0174f.1553622380.18.1554212685.1554212685.; JSESSIONID=2WhvcjnDDmQZBcVbDcRwGtTCWt1kvrqf2f9whYBS29TZgL2VXTqR!-1646886097!896799599; BIGipServerPool_Citas_Mexitel=!FjhUZgRUHJc23PaxNCpVW2wfI9iVo/K1FHjaCrgGdah6LwnZauCS8WsSdMOTuGKtdFfQMGQj/PvoIQ==; _pk_ses.2.170d=1; _gid=GA1.3.1156628238.1554212693

        Upgrade-Insecure-Requests: 1

        And, this is my header request:

        request.setHeader(QNetworkRequest::ContentTypeHeader, "text/html; charset=UTF-8");
        request.setHeader(QNetworkRequest::UserAgentHeader, "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0");
        request.setRawHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8");
        request.setRawHeader("Accept-Language","es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3");
        request.setRawHeader("Accept-Encoding","gzip, deflate, br");
        request.setRawHeader("Connection","keep-alive");
        request.setRawHeader("Cookie","__cfduid=d74b1e92b11332b88ec011ff9d4175f1d1553622050; _ga=GA1.3.837904067.1553622282; _pk_id.2.170d=160538fce0b0174f.1553622380.18.1554212685.1554212685.; JSESSIONID=2WhvcjnDDmQZBcVbDcRwGtTCWt1kvrqf2f9whYBS29TZgL2VXTqR!-1646886097!896799599; BIGipServerPool_Citas_Mexitel=!FjhUZgRUHJc23PaxNCpVW2wfI9iVo/K1FHjaCrgGdah6LwnZauCS8WsSdMOTuGKtdFfQMGQj/PvoIQ==; _pk_ses.2.170d=1; _gid=GA1.3.1156628238.1554212693");
        request.setRawHeader("Upgrade-Insecure-Requests","1");

        Is the same. when i put when i put

        qDebug() << request.rawHeaderList();

        the system recognize the headers

        ("Content-Type", "User-Agent", "Accept", "Accept-Language", "Accept-Encoding", "Connection", "Cookie", "Upgrade-Insecure-Requests")

        But i have the same error

        QNetworkReply::ContentAccessDenied
        403 "Forbidden"

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved