"""CLI configuration management."""

import logging

from slices_clientlib_core.base.auth import load_auth_token as core_load_auth_token
from slices_clientlib_core.base.exceptions import ConfigurationError
from slices_clientlib_core.oauth2.token import OAuthToken

from . import err_console

logger = logging.getLogger(__name__)


def load_auth_token() -> OAuthToken | None:
    """Load authentication token from file."""
    try:
        return core_load_auth_token()
    except ConfigurationError as err:
        err_console.print("[bold red]Could not load auth token from external provider :x:")
        err_console.print(f"[red]{err}")
