feat(superoffice): POC API handshake & auth flow [2ff88f42]

Establishes the initial structure for the SuperOffice connector. Implements the complete, iterative authentication process, culminating in a successful refresh token exchange. Documents the process and the final blocker (API authorization) in the integration plan, awaiting IT action to change the application type to 'Server to server'.
This commit is contained in:
2026-02-06 13:52:44 +00:00
parent 0f9e651d95
commit 53b92c76de
10 changed files with 310 additions and 24 deletions

View File

@@ -2,20 +2,71 @@ import os
import logging
from dotenv import load_dotenv
# Setup basic logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# Import the new classes
from .auth_handler import AuthHandler
from .superoffice_client import SuperOfficeClient
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler()
]
)
logger = logging.getLogger(__name__)
# Load environment variables
load_dotenv()
def main():
logger.info("Starting SuperOffice Connector...")
"""
Main function to initialize and run the SuperOffice connector.
"""
logger.info("Starting SuperOffice Connector Proof of Concept...")
# Load environment variables from the root .env file
dotenv_path = os.path.join(os.path.dirname(__file__), '..', '.env')
logger.info(f"Attempting to load .env file from: {dotenv_path}")
# TODO: Implement authentication logic here using Gemini CLI
# TODO: Implement Polling / Sync logic here
logger.info("Connector stopped.")
if os.path.exists(dotenv_path):
load_dotenv(dotenv_path=dotenv_path)
logger.info(".env file loaded successfully.")
else:
logger.error(f".env file not found at the expected location: {dotenv_path}")
logger.error("Please ensure the .env file exists in the project root directory.")
return
try:
# 1. Initialize AuthHandler
auth_handler = AuthHandler()
# Define the tenant ID
TENANT_ID = "Cust26720" # As provided in the initial task description
# 2. Get a fresh access token (this will also update the refresh token if needed)
full_access_token = auth_handler.get_access_token()
logger.info(f"Full Access Token for curl: {full_access_token}")
# 3. Initialize SuperOfficeClient with the tenant ID
so_client = SuperOfficeClient(auth_handler, TENANT_ID)
# 3. Perform test connection
logger.info("--- Performing Connection Test ---")
connection_result = so_client.test_connection()
logger.info("--- Connection Test Finished ---")
if connection_result:
logger.info("POC Succeeded: Connection to SuperOffice API was successful.")
else:
logger.error("POC Failed: Could not establish a connection to SuperOffice API.")
except ValueError as ve:
logger.error(f"Configuration Error: {ve}")
logger.error("POC Failed due to missing configuration.")
except Exception as e:
logger.error(f"An unexpected error occurred during the POC execution: {e}", exc_info=True)
logger.error("POC Failed due to an unexpected error.")
logger.info("SuperOffice Connector POC finished.")
if __name__ == "__main__":
main()
main()