Access Token Question

  • Hi,

    I'm confused about how access tokens work when authenticating to the backend from c++. I have a class where I am setting up the connection and authenticating in my constructor. I'm not sure how tokens are handled. Will the authentication eventually time out? If so, how do it renew it when I want to access the back end again? Here is what I have so far. It works fine for authenticating and uploading objects.

    @#include "cloudWorker.h"
    #include <QDebug>
    #include <QObject>
    #include <QString>
    #include <Enginio/Enginio>


    QByteArray backendId("backEndId");
    client = new EnginioClient;
    connect(client, SIGNAL(finished(EnginioReply*)), this, SLOT(uploadFinished(EnginioReply*)));
    connect(client, SIGNAL(sessionAuthenticated(EnginioReply*)), this,  SLOT(onSessionAuthenticated(EnginioReply*)));
    connect(client, SIGNAL(sessionAuthenticationError(EnginioReply*)), this, SLOT(onSessionAuthenticatedError(EnginioReply*)));
    EnginioOAuth2Authentication *identity = new EnginioOAuth2Authentication(client);




    // slot
    void CloudWorker::uploadFinished(EnginioReply* reply)

    jsonResult = reply->data().toVariantMap();
    emit resultsReady();


    void CloudWorker::onSessionAuthenticated(EnginioReply* reply)

    qDebug() << reply;


    void CloudWorker::onSessionAuthenticatedError(EnginioReply* reply)

    qDebug() << reply->data().value("error_description").toString();


    QVariantMap CloudWorker::getResults()
    return jsonResult;

    void CloudWorker::uploadObjects()
    QJsonObject test;

    test.insert("objectType", QString("objects.test")); // an object type is required for all objects in Enginio
    test.insert("title", QString("titleTest")); // other properties can be chosen freely



  • I can't understand why the documentation on gives examples for obtaining access tokens using curl but not c++. Its Qt Cloud Services right?!

  • Hi,

    I guess you can obtain a new token by calling setIdentity again ..?

    The other problem is detecting that the previous token has expired, but that problem also exists when using directly the REST API. The C++ API is only a wrapper of the REST API.
    When the token expires (after at least one hour), for a GET the error "Invalid bearer token" is informative, but for a POST you only have a 400 error, so you have to guess that the token is invalid.

  • Yeah the documentation is not at all clear on the matter. The c++/QML api's are what constitute value for QtCloudServices as far as I'm concerned. If I am going to go through the hassle of accessing the back end through the REST api then I have less expensive and more established options for a back end. I'm hoping that this is just a matter of the api's being in a state of transition.

  • Hi! One of our Qt Cloud Services Team member has been working for a while on a new Qt/C++ SDK for Qt Cloud Services which works like most common cloud platform SDKs. We feel it's essential to have SDK with full control over platform and the features. In fact, we have been working to create SDK that works in similar way across different programming languages.

    You can take a look at this new SDK for C++ and Qt in Github at:



    Note: These SDK projects are "community" projects and are not officially supported by Qt Cloud Services Team. However, they might provide the features you are looking for.

Log in to reply

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