File size: 301 Bytes
bcd2179
 
 
 
 
 
 
1
2
3
4
5
6
7
8
from fastapi import Header, HTTPException

def x_api_key_auth(x_api_key: str = Header(...)):
    expected_api_key = "your_expected_api_key"  # Replace with your actual API key
    if x_api_key != expected_api_key:
        raise HTTPException(status_code=401, detail="Invalid API Key")
    return True