Completed POC for SuperOffice integration with the following key achievements: - Switched from RSA/SOAP to OAuth 2.0 (Refresh Token Flow) for better compatibility with SOD environment. - Implemented robust token refreshing and caching mechanism in . - Solved 'Wrong Subdomain' issue by enforcing for tenant . - Created for REST API interaction (Search, Create, Update UDFs). - Added helper scripts: , , . - Documented usage and configuration in . - Updated configuration requirements. [2ff88f42]
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
import os
|
|
import logging
|
|
import json
|
|
from dotenv import load_dotenv
|
|
from auth_handler import AuthHandler
|
|
from superoffice_client import SuperOfficeClient
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
def discover_fields():
|
|
load_dotenv(dotenv_path="../.env")
|
|
auth = AuthHandler()
|
|
client = SuperOfficeClient(auth)
|
|
|
|
logger.info("Fetching metadata to discover UDF fields...")
|
|
|
|
# Get metadata for Contact (Company)
|
|
url = client._get_url("v1/Metadata/Contact/UserDefinedFields")
|
|
try:
|
|
resp = client.session.get(url, headers=client._get_headers())
|
|
resp.raise_for_status()
|
|
fields = resp.json()
|
|
|
|
print("\n--- AVAILABLE UDF FIELDS ---")
|
|
for field in fields.get("value", []):
|
|
print(f"Label: {field.get('FieldLabel')} -> Technical Name: {field.get('ProgId')} (Type: {field.get('FieldType')})")
|
|
|
|
except Exception as e:
|
|
logger.error(f"Failed to fetch metadata: {e}")
|
|
if hasattr(e, 'response') and e.response is not None:
|
|
print(f"Details: {e.response.text}")
|
|
|
|
if __name__ == "__main__":
|
|
discover_fields()
|
|
|