OAuth2 do not receive token
-
Hi,
I am trying to connect to the API of BimCollab Connection API .
Using Qt's QOAuth2AuthorizationCodeFlow class.
I get the code back after the authentication request but then the token request to the server is lost.
When I send the URL I received via Postman, I get the token back.
Authentication:

Code snippet:
mReplyHandler = std::make_unique<QOAuthHttpServerReplyHandler>(QHostAddress::LocalHost, 5000); // qDebug() << mReplyHandler->callback() << mReplyHandler->port(); // // mReplyHandler->setCallbackPath("Callback"); // mOAuth2->setModifyParametersFunction([=](QAbstractOAuth::Stage stage, QVariantMap* params) { switch (stage) { case QAbstractOAuth::Stage::RequestingAuthorization: params->insert("response_type", "code"); params->insert("redirect_uri", "http://localhost:5000/Callback"); params->insert("scope", "openid offline_access bcf"); params->insert("code_challenge_method", "S256"); break; case QAbstractOAuth::Stage::RequestingAccessToken: // qDebug() << "PARAMS CODE" << params->value("code"); params->insert("code", QUrl::fromPercentEncoding(params->value("code").toByteArray())); break; case QAbstractOAuth::Stage::RequestingTemporaryCredentials: qDebug() << params; break; case QAbstractOAuth::Stage::RefreshingAccessToken: break; default: break; } }); mOAuth2->setAuthorizationUrl(mAuthentication.mOauth2AuthUrl.GetQString()); mOAuth2->setAccessTokenUrl(mAuthentication.mOauth2TokenUrl.GetQString()); mOAuth2->setClientIdentifierSharedKey("k!xWcjad!u@L%ZWHc%%yKtMTqR%o1be@qWfWYaDL"); mOAuth2->setClientIdentifier("PlayGround_Client");Console output:
QtDebug: SSL build version => "OpenSSL 1.1.1m 14 Dec 2021" QtDebug: QSslSocket::supportsSSL() true QtDebug: SSL version => "OpenSSL 1.1.1c 28 May 2019" QtDebug: "http://127.0.0.1:5000/" 5000 QtDebug: "authorization_code_grant" QtDebug: "resource_owner_password_credentials_grant" QtDebug: is ReplyHandlerServer listening ? true QtDebug: authorizationCallbackReceived QtDebug: TemporaryCredentialsReceived QtDebug: PARAMS CODE QVariant(QByteArray, "FE6EDAC15ED6032D998379F792CA0FF1765DD680970E56370985E1FF5DC16E82") QtDebug: authorizationCallbackReceived QtWarning: Unexpected call QtWarning: Error transferring https://playground.bimcollab.com/identity/connect/token - server replied: Bad Request -
solved with
case QAbstractOAuth::Stage::RequestingAccessToken: params->insert("code", params->value("code")); params->insert("redirect_uri", "http://localhost:5000/Callback"); params->insert("scope", "openid offline_access bcf"); params->insert("code_challenge_method", "S256"); break;