""" Credential lookup, in priority order: 1. Environment variables (set as "Secrets" in a Hugging Face Space) -- FB_PAGE_ID and FB_ACCESS_TOKEN. 2. Values saved in the local database via the Settings tab. Using Space secrets means the token is never stored in the app's SQLite file and never shown/editable in the UI -- it only lives in the Space's encrypted secret store and the process environment. """ import os import database as db ENV_PAGE_ID = "FB_PAGE_ID" ENV_ACCESS_TOKEN = "FB_ACCESS_TOKEN" def using_env_secrets() -> bool: return bool(os.environ.get(ENV_PAGE_ID) and os.environ.get(ENV_ACCESS_TOKEN)) def get_page_id(): return os.environ.get(ENV_PAGE_ID) or db.get_setting("page_id") def get_access_token(): return os.environ.get(ENV_ACCESS_TOKEN) or db.get_setting("access_token") def is_configured() -> bool: return bool(get_page_id() and get_access_token())