Skip to content

Commit

Permalink
[FIX] account_statement_import_online_gocardless : Correction of the …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
arpol-dev committed Dec 14, 2024
1 parent 03806fb commit 2131017
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Check warning on line 90 in account_statement_import_online_gocardless/models/online_bank_statement_provider.py

View check run for this annotation

Codecov / codecov/patch

account_statement_import_online_gocardless/models/online_bank_statement_provider.py#L90

Added line #L90 was not covered by tests
else:
endpoint = "token/new"
request_data={"secret_id": self.username, "secret_key": self.password}

Check warning on line 93 in account_statement_import_online_gocardless/models/online_bank_statement_provider.py

View check run for this annotation

Codecov / codecov/patch

account_statement_import_online_gocardless/models/online_bank_statement_provider.py#L93

Added line #L93 was not covered by tests
_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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@
* `Alusage <https://nicolas.alusage.fr>`__:

* Nicolas JEUDY <https://github.com/njeudy>
* `ArPol <https://arpol.fr>`__:

* Armand POLMARD <https://github.com/arpol-dev>

0 comments on commit 2131017

Please sign in to comment.