import os
from typing import Optional
from dotenv import load_dotenv
from .exceptions import AuthenticationException
load_dotenv()
class AuthManager:
"""Manages ClickUp API authentication"""
def __init__(self, api_token: Optional[str] = None):
self.api_token = api_token or os.getenv("CLICKUP_API_TOKEN")
if not self.api_token:
raise AuthenticationException("ClickUp API token not provided")
def get_headers(self) -> dict:
"""Get authentication headers for API requests"""
return {
"Authorization": self.api_token,
"Content-Type": "application/json"
}
def validate_token(self) -> bool:
"""Validate the API token format"""
return bool(self.api_token and len(self.api_token) > 0)