diff --git a/modules/features/trustee/accounting/connectors/accountingConnectorRma.py b/modules/features/trustee/accounting/connectors/accountingConnectorRma.py index b836b03c..4ec1ebd7 100644 --- a/modules/features/trustee/accounting/connectors/accountingConnectorRma.py +++ b/modules/features/trustee/accounting/connectors/accountingConnectorRma.py @@ -3,7 +3,7 @@ """Run My Accounts (Infoniqa) accounting connector. API docs: https://runmyaccountsag.github.io/runmyaccounts-rest-api/ -Auth: Static API key via X-RMA-KEY header. +Auth: API key (incl. ``pat_`` tokens since Sep 2025) via ``X-RMA-KEY`` request header. Base URL: https://service.runmyaccounts.com/api/latest/clients/{clientName}/ """ @@ -59,11 +59,10 @@ class AccountingConnectorRma(BaseAccountingConnector): return f"{_BASE_URL}/{clientName}/{resource}" def _buildHeaders(self, config: Dict[str, Any]) -> Dict[str, str]: - """PAT must not be in query params; RMA expects Authorization header.""" apiKey = config.get("apiKey", "") return { - "Authorization": f"Bearer {apiKey}", - "Accept": "application/json, application/xml, */*", # RMA may return XML on error (e.g. 406) + "X-RMA-KEY": apiKey, + "Accept": "application/json, application/xml, */*", "Content-Type": "application/json", } @@ -76,6 +75,7 @@ class AccountingConnectorRma(BaseAccountingConnector): url = self._buildUrl(config, "customers") headers = self._buildHeaders(config) + logger.info("RMA testConnection: url=%s, clientName=%s, apiKey=%s...", url, clientName, apiKey[:6] if len(apiKey) > 6 else "***") try: async with aiohttp.ClientSession() as session: async with session.get(url, headers=headers, timeout=aiohttp.ClientTimeout(total=15)) as resp: @@ -83,6 +83,7 @@ class AccountingConnectorRma(BaseAccountingConnector): logger.info("RMA connection successful") return SyncResult(success=True) body = await resp.text() + logger.warning("RMA testConnection failed: status=%s, url=%s, body=%s", resp.status, url, body[:500]) return SyncResult(success=False, errorMessage=f"HTTP {resp.status}: {body[:300]}") except Exception as e: return SyncResult(success=False, errorMessage=str(e))