[2ff88f42] refactor(connector-superoffice): finalize production readiness cleanup

- Integrated centralized logging system in all modules.
- Extracted all IDs and ProgIds into a separate .
- Refactored  and  for cleaner dependency management.
- Included updated discovery and inspection utilities.
- Verified end-to-end workflow stability.
This commit is contained in:
2026-02-10 12:43:26 +00:00
parent 1ea17695ec
commit 005c947dae
9 changed files with 185 additions and 255 deletions

View File

@@ -1,38 +1,37 @@
import os
import logging
import time
import requests
from config import Config
from logging_config import setup_logging
logger = logging.getLogger(__name__)
logger = setup_logging(__name__)
class AuthHandler:
def __init__(self):
# Load configuration from environment
self.client_id = os.getenv("SO_CLIENT_ID")
if not self.client_id:
self.client_id = os.getenv("SO_SOD")
if self.client_id:
logger.info("Using SO_SOD as Client ID")
else:
logger.info("Using SO_CLIENT_ID as Client ID")
self.client_secret = os.getenv("SO_CLIENT_SECRET")
self.refresh_token = os.getenv("SO_REFRESH_TOKEN")
self.tenant_id = os.getenv("SO_CONTEXT_IDENTIFIER") # e.g., Cust55774
# Load configuration from Config class
self.client_id = Config.SO_CLIENT_ID
self.client_secret = Config.SO_CLIENT_SECRET
self.refresh_token = Config.SO_REFRESH_TOKEN
self.tenant_id = Config.SO_CONTEXT_IDENTIFIER # e.g., Cust55774
# OAuth Token Endpoint for SOD
# OAuth Token Endpoint for SOD (Could be configurable in future)
self.token_url = "https://sod.superoffice.com/login/common/oauth/tokens"
self._access_token = None
self._webapi_url = None
self._expiry = 0
if not self.client_id:
logger.error("SO_CLIENT_ID (or SO_SOD) is not set in environment!")
def get_ticket(self):
if self._access_token and time.time() < self._expiry:
return self._access_token, self._webapi_url
return self.refresh_access_token()
def refresh_access_token(self):
if not self.client_id:
raise ValueError("Client ID is missing. Cannot refresh token.")
logger.info(f"Refreshing Access Token for Client ID: {self.client_id[:5]}...")
payload = {