<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Add parameter to QOAuth2AuthorizationCodeFlow using setModifyParametersFunction]]></title><description><![CDATA[<p dir="auto">I am working on a Qt project. I want to establish permanent access to Reddit API using the <code>refresh_token</code> that reddit's OAuth Authentication provides after successful authentication and that Qt's <code>QOAuth2AuthorizationCodeFlow</code> does support.</p>
<p dir="auto">The only problem being that Reddit's OAuth requires the parameter <code>duration</code> to be set to <code>permanent</code> as a part of the authentication request in order to receive a <code>refresh_token</code>. <code>duration</code> seems to be a non-standard parameter as <code>QOAuth2AuthorizationCodeFlow</code> does not have a direct way to set the duration.</p>
<p dir="auto">I tried using <code>setModifyParametersFunction</code> like so but it did not work</p>
<pre><code class="language-cpp">QOAuth2AuthorizationCodeFlow 

auto replyHandler = new QOAuthHttpServerReplyHandler(QHostAddress::Any, 1337, this);
oauth2.setReplyHandler(replyHandler);
oauth2.setAuthorizationUrl(QUrl(authorizationUrl));
oauth2.setTokenUrl(QUrl(accessTokenUrl));
oauth2.setClientIdentifier(clientId);
const QSet&lt;QByteArray&gt; scope = {QByteArray("identity"), QByteArray("read")};
oauth2.setRequestedScopeTokens(scope);

// Tried to add it here
oauth2.setModifyParametersFunction([](QAbstractOAuth::Stage stage, QMultiMap&lt;QString, QVariant&gt; *parameters) {
    if (!parameters)
        return; // Abort if pointer is invalid

    if (stage == QAbstractOAuth::Stage::RequestingAccessToken) {
        parameters-&gt;insert("duration"_L1, "permanent"_L1);
    }
});
</code></pre>
<p dir="auto">Can somebody explain why this did not work? Is this an issue at the reddit side or did I just use the function incorrectly?</p>
]]></description><link>https://forum.qt.io/topic/161831/add-parameter-to-qoauth2authorizationcodeflow-using-setmodifyparametersfunction</link><generator>RSS for Node</generator><lastBuildDate>Mon, 15 Jun 2026 01:25:40 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/161831.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 17 Apr 2025 14:48:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Add parameter to QOAuth2AuthorizationCodeFlow using setModifyParametersFunction on Thu, 01 May 2025 11:26:04 GMT]]></title><description><![CDATA[<p dir="auto">I'm sorry for not replying for so long...</p>
<p dir="auto">The lambda was getting triggered, and as you pointed out, the stage I was checking for was wrong. I needed to modify them at  <code>QAbstractOAuth::Stage::RequestingAuthorization</code>, not at <code>QAbstractOAuth::Stage::RequestingAccessToken</code>.</p>
<p dir="auto">Anyways, thanks for the quick reply!</p>
]]></description><link>https://forum.qt.io/post/825512</link><guid isPermaLink="true">https://forum.qt.io/post/825512</guid><dc:creator><![CDATA[codeIMperfect]]></dc:creator><pubDate>Thu, 01 May 2025 11:26:04 GMT</pubDate></item><item><title><![CDATA[Reply to Add parameter to QOAuth2AuthorizationCodeFlow using setModifyParametersFunction on Thu, 17 Apr 2025 19:06:09 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">Might be a silly question but are you sure your lambda is called ? If so, is it called for all the expected stages ?</p>
]]></description><link>https://forum.qt.io/post/824788</link><guid isPermaLink="true">https://forum.qt.io/post/824788</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 17 Apr 2025 19:06:09 GMT</pubDate></item></channel></rss>