import os
import json
import requests


def _auth_headers():
    token = os.getenv("FARMOS_TOKEN")
    if token:
        return {"Authorization": f"Bearer {token}"}
    user = os.getenv("FARMOS_USER")
    pwd = os.getenv("FARMOS_PASSWORD")
    if user and pwd:
        import base64
        auth = base64.b64encode(f"{user}:{pwd}".encode()).decode()
        return {"Authorization": f"Basic {auth}"}
    return {}
