From 271ae917e4ab02e9456f38224cfca17609f64b87 Mon Sep 17 00:00:00 2001 From: ArPol Date: Sun, 15 Dec 2024 11:43:06 +0100 Subject: [PATCH] [16.0][FIX] account_statement_import_online_gocardless : Correction of the endpoint token/refresh request datas, plus the behavior of the _gocardless_get_token method which in case of a non expired refresh token was calling the endpoint token/new instead of token/refresh --- account_statement_import_online_gocardless/README.rst | 3 +++ .../models/online_bank_statement_provider.py | 8 ++++---- .../readme/CONTRIBUTORS.rst | 3 +++ .../static/description/index.html | 4 ++++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/account_statement_import_online_gocardless/README.rst b/account_statement_import_online_gocardless/README.rst index 1d00bf1db..749782532 100644 --- a/account_statement_import_online_gocardless/README.rst +++ b/account_statement_import_online_gocardless/README.rst @@ -129,6 +129,9 @@ Contributors * `Alusage `__: * Nicolas JEUDY +* `ArPol `__: + + * Armand POLMARD Maintainers ~~~~~~~~~~~ diff --git a/account_statement_import_online_gocardless/models/online_bank_statement_provider.py b/account_statement_import_online_gocardless/models/online_bank_statement_provider.py index 11875253b..076994ab8 100644 --- a/account_statement_import_online_gocardless/models/online_bank_statement_provider.py +++ b/account_statement_import_online_gocardless/models/online_bank_statement_provider.py @@ -84,17 +84,17 @@ def _gocardless_get_token(self): # Refresh token if ( self.gocardless_refresh_token - and now > self.gocardless_refresh_expiration + and now < self.gocardless_refresh_expiration ): endpoint = "token/refresh" + request_data = {"refresh": self.gocardless_refresh_token} else: endpoint = "token/new" + request_data = {"secret_id": self.username, "secret_key": self.password} _response, data = self._gocardless_request( endpoint, request_type="post", - data=json.dumps( - {"secret_id": self.username, "secret_key": self.password} - ), + data=json.dumps(request_data), basic_auth=True, ) expiration_date = now + relativedelta(seconds=data.get("access_expires", 0)) diff --git a/account_statement_import_online_gocardless/readme/CONTRIBUTORS.rst b/account_statement_import_online_gocardless/readme/CONTRIBUTORS.rst index a7d7525ea..dd9c55f91 100644 --- a/account_statement_import_online_gocardless/readme/CONTRIBUTORS.rst +++ b/account_statement_import_online_gocardless/readme/CONTRIBUTORS.rst @@ -8,3 +8,6 @@ * `Alusage `__: * Nicolas JEUDY +* `ArPol `__: + + * Armand POLMARD diff --git a/account_statement_import_online_gocardless/static/description/index.html b/account_statement_import_online_gocardless/static/description/index.html index 54b0566a0..12e767e19 100644 --- a/account_statement_import_online_gocardless/static/description/index.html +++ b/account_statement_import_online_gocardless/static/description/index.html @@ -494,6 +494,10 @@

Contributors

  • Nicolas JEUDY <https://github.com/njeudy>
  • +
  • ArPol: +