diff options
| author | Juha Vuolle <juha.vuolle@qt.io> | 2024-09-05 11:56:12 +0300 |
|---|---|---|
| committer | Juha Vuolle <juha.vuolle@qt.io> | 2024-10-09 09:27:45 +0300 |
| commit | 235f475c560224295facb5473034e6d4d0188c95 (patch) | |
| tree | ad22709bba06608f3412873a59b79373046ba4e9 /src/oauth/qoauth2authorizationcodeflow.cpp | |
| parent | 47f3d2b6190360fa0c3c442014f97184e78df5d2 (diff) | |
Add token request modification possibility
This commit adds means to set a callback that is called
just prior to sending out either access token or refresh
token requests. This allows making any necessary adjustments
to the QNetworkRequest, in case the token endpoint requires
some specific headers or other values.
[ChangeLog][QAbstractOAuth2] Added new function setter for modifying
token network requests
Fixes: QTBUG-65309
Change-Id: I7ab99dac891c30e1d3bcc967a879c07e35e7ba85
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/oauth/qoauth2authorizationcodeflow.cpp')
| -rw-r--r-- | src/oauth/qoauth2authorizationcodeflow.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/oauth/qoauth2authorizationcodeflow.cpp b/src/oauth/qoauth2authorizationcodeflow.cpp index 1e3999f..121362a 100644 --- a/src/oauth/qoauth2authorizationcodeflow.cpp +++ b/src/oauth/qoauth2authorizationcodeflow.cpp @@ -507,6 +507,8 @@ void QOAuth2AuthorizationCodeFlow::refreshAccessToken() request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded")); + d->callTokenRequestModifier(request, QAbstractOAuth::Stage::RefreshingAccessToken); + const QString data = query.toString(QUrl::FullyEncoded); d->currentReply = d->networkAccessManager()->post(request, data.toUtf8()); setStatus(Status::RefreshingToken); @@ -609,6 +611,9 @@ void QOAuth2AuthorizationCodeFlow::requestAccessToken(const QString &code) QStringLiteral("application/x-www-form-urlencoded")); const QString data = query.toString(QUrl::FullyEncoded); + + d->callTokenRequestModifier(request, QAbstractOAuth::Stage::RequestingAccessToken); + QNetworkReply *reply = d->networkAccessManager()->post(request, data.toUtf8()); d->currentReply = reply; QAbstractOAuthReplyHandler *handler = replyHandler(); |
