diff --git a/src/openforms/contrib/haal_centraal/clients/__init__.py b/src/openforms/contrib/haal_centraal/clients/__init__.py index 24e656c274..5824ef084e 100644 --- a/src/openforms/contrib/haal_centraal/clients/__init__.py +++ b/src/openforms/contrib/haal_centraal/clients/__init__.py @@ -60,6 +60,13 @@ def get_brp_client(submission: Submission | None = None, **kwargs: Any) -> BRPCl f"No suitable client class configured for API version {version}" ) + if submission: + kwargs.setdefault("context", {}) + # pass submission to ensure token exchange works properly + # only do this if the submission is not None, to avoid unnecessary database queries + # done by token_exchange.auth.TokenAccessAuth + kwargs["context"]["submission"] = submission + return build_client( service, client_factory=ClientCls, diff --git a/src/openforms/prefill/contrib/haalcentraal_brp/plugin.py b/src/openforms/prefill/contrib/haalcentraal_brp/plugin.py index 2c7507bb6f..43ae3a9d7d 100644 --- a/src/openforms/prefill/contrib/haalcentraal_brp/plugin.py +++ b/src/openforms/prefill/contrib/haalcentraal_brp/plugin.py @@ -13,7 +13,6 @@ from openforms.contrib.haal_centraal.constants import BRPVersions from openforms.contrib.haal_centraal.models import HaalCentraalConfig from openforms.plugins.exceptions import InvalidPluginConfiguration -from openforms.pre_requests.clients import PreRequestClientContext from openforms.submissions.models import Submission from ...base import BasePlugin @@ -111,10 +110,7 @@ def get_prefill_values( identifier_role: IdentifierRoles = IdentifierRoles.main, ) -> dict[str, Any]: try: - client = get_brp_client( - submission=submission, - context=PreRequestClientContext(submission=submission), - ) + client = get_brp_client(submission=submission) except NoServiceConfigured: return {} @@ -141,10 +137,7 @@ def get_co_sign_values( the value is the prefill value to use for that attribute. """ try: - client = get_brp_client( - submission=submission, - context=PreRequestClientContext(submission=submission), - ) + client = get_brp_client(submission=submission) except NoServiceConfigured: return ({}, "")