File size: 600 Bytes
44459bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"""Headers for HTTP requests."""

from folding_studio.config import FOLDING_API_KEY
from folding_studio.utils.gcp import get_id_token


def get_auth_headers() -> dict[str, str]:
    """
    Create authentication headers based on available credentials.

    API key is the default authentication.
    If none is provided, we fallback to JWT from Google Cloud.

    Returns:
        dict: Authentication headers for API requests.
    """
    if FOLDING_API_KEY:
        return {"X-API-Key": FOLDING_API_KEY}

    identity_token = get_id_token()
    return {"Authorization": f"Bearer {identity_token}"}