Skip to content

Commit

Permalink
Ensure refresh body is fully encoded
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 11, 2023
1 parent f15a7dc commit 37d64fd
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions koordinates/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
from qgis.PyQt.QtCore import (
QThread,
pyqtSignal,
QUrl
QUrl,
QUrlQuery
)
from qgis.PyQt.QtGui import QDesktopServices
from qgis.PyQt.QtNetwork import (
Expand Down Expand Up @@ -212,16 +213,17 @@ def __init__(self):
self._refresh_kx_key_reply: Optional[QNetworkReply] = None

def refresh(self, refresh_token: str):
body = (f"grant_type=refresh_token&"
f"client_id={CLIENT_ID}&"
f"refresh_token={refresh_token}")
query = QUrlQuery()
query.addQueryItem('grant_type', 'refresh_token')
query.addQueryItem('client_id', CLIENT_ID)
query.addQueryItem('refresh_token', refresh_token)

network_request = QNetworkRequest(QUrl(TOKEN_URL))
network_request.setHeader(QNetworkRequest.ContentTypeHeader,
'application/x-www-form-urlencoded')
self._refresh_reply = QgsNetworkAccessManager.instance().post(
network_request,
body.encode()
query.toString(QUrl.FullyEncoded).encode()
)
self._refresh_reply.finished.connect(
partial(self._refresh_oauth_finished, self._refresh_reply))
Expand Down

0 comments on commit 37d64fd

Please sign in to comment.