[SOLVED] Login with EnginioClient in C++

  • Hello everybody,

    I write an application with Qt/QML to access the EDS.

    So far I implemented the registration form, which works as expected. But I can't login using EnginioClient.

    My code is as following
    @EnginoClient client;

    QObject::connect(&client, &EnginioClient::finished, this, &Login::finished);
    QObject::connect(&client, &EnginioClient::error, this, &Login::error);
    QObject::connect(&client, &EnginioClient::sessionAuthenticated, this, &Login::sessionAuthenticated);
    QObject::connect(&client, &EnginioClient::sessionAuthenticationError, this, &Login::sessionAuthenticationError);

    EnginioOAuth2Authentication identity;


    I followed "this":http://qt-project.org/doc/qt-5/enginiooauth2authentication.html approach, but nothing happens.
    Neigther of the signals returns my debug message.

    Can anyone help me?

  • Is it possible that there was a change in the api?

    I also tried a workaround with the QNetworkAccessManager which was working in the past.
    Here is my code:
    @ QUrlQuery requestQuery;
    requestQuery.addQueryItem("grant_type", "password");
    requestQuery.addQueryItem("username", username);
    requestQuery.addQueryItem("password", password);

    QNetworkRequest request(QUrl(_baseUrl + "/auth/oauth2/token"));
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded;charset=UTF-8");
    request.setRawHeader("Enginio-Backend-Id", _backendId);
    qDebug() << "request: " + request.url().toString();
    qDebug() << "requestQuery: " + requestQuery.query(QUrl::FullyEncoded).toUtf8();
    QNetworkReply *reply = _qnam->post(request, requestQuery.query(QUrl::FullyEncoded).toUtf8());
    QObject::connect(reply, SIGNAL(finished()), this, SLOT(loginFinished()));


    If the user credentials aren't correct I can see a corresponding error. But when I enter everything correctly I just receive a "Internal server error".

    Any suggestions here?

    Thank you

  • Solved it!

    You have to add:
    @request.setRawHeader("Accept", "application/json");@

  • Well just check if the Identity object is not removed.
    I have seen that you allocated everything on stack which means that as soon you leave the scope the identity object is removed. I guess it would happen much faster then the network round trip.

    The docs needs to be updated to use new operator, you are not the first one which fall into this trap.

Log in to reply

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