Problem is calling cloud print search api



  • 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


  • Moderators

    @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.



  • @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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.