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. Problem is calling cloud print search api
Forum Updated to NodeBB v4.3 + New Features

Problem is calling cloud print search api

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 744 Views
  • 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.
  • bhupiB Offline
    bhupiB Offline
    bhupi
    wrote on last edited by
    #1

    I am trying to call cloud print search api form my desktop application.

    https://developers.google.com/cloud-print/docs/appInterfaces#calling-syntax

    Below is my working code so far.

    QString httpRequest;
    
    httpRequest = "https://www.google.com/cloudprint/search";
    
    QEventLoop loop;
    
    QNetworkAccessManager mNetworkManager;
    
    QObject::connect(&mNetworkManager, SIGNAL(finished(QNetworkReply *)),
                        &loop, SLOT(quit()));
    
    QNetworkRequest request;
    request.setUrl(QUrl(httpRequest));
    
    request.setRawHeader("Authorization" ,accessToken.toUtf8());
    request.setRawHeader("Content-Type" ,"application/json");
    request.setRawHeader("Host" ,"www.google.com");
    
    QNetworkReply *rep = mNetworkManager.get(request);
    
    QObject::connect(&mNetworkManager, SIGNAL(finished(QNetworkReply *)),
    this, SLOT(Onfinish(QNetworkReply *)));
    
    loop.exec();
    

    I am getting error ContentOperationNotPermittedError.

    I know its issue related to access but what is wrong with the above implementation i am not getting that. I am generating access token using aouth 2.0 . I have also tested above api using google playground successfully.

    thanks

    raven-worxR 1 Reply Last reply
    0
    • bhupiB bhupi

      I am trying to call cloud print search api form my desktop application.

      https://developers.google.com/cloud-print/docs/appInterfaces#calling-syntax

      Below is my working code so far.

      QString httpRequest;
      
      httpRequest = "https://www.google.com/cloudprint/search";
      
      QEventLoop loop;
      
      QNetworkAccessManager mNetworkManager;
      
      QObject::connect(&mNetworkManager, SIGNAL(finished(QNetworkReply *)),
                          &loop, SLOT(quit()));
      
      QNetworkRequest request;
      request.setUrl(QUrl(httpRequest));
      
      request.setRawHeader("Authorization" ,accessToken.toUtf8());
      request.setRawHeader("Content-Type" ,"application/json");
      request.setRawHeader("Host" ,"www.google.com");
      
      QNetworkReply *rep = mNetworkManager.get(request);
      
      QObject::connect(&mNetworkManager, SIGNAL(finished(QNetworkReply *)),
      this, SLOT(Onfinish(QNetworkReply *)));
      
      loop.exec();
      

      I am getting error ContentOperationNotPermittedError.

      I know its issue related to access but what is wrong with the above implementation i am not getting that. I am generating access token using aouth 2.0 . I have also tested above api using google playground successfully.

      thanks

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @bhupi
      ContentOperationNotPermittedError = HTTP error 403 = Access Denied

      How do you create the OAuth tokens? Make sure you create them with the same network access manager you use to send your requests. Or at least make sure you transfer them from the other QNAM.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • bhupiB Offline
        bhupiB Offline
        bhupi
        wrote on last edited by bhupi
        #3

        @raven-worx

        Please see below link for the code file now i am using single object to retrieve access token and to call search api.

        https://www.dropbox.com/s/ggwg4akefrwn5if/oauth2service.cpp?dl=0

        I am getting same error.

        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