mirror of
https://gitlab.sectorq.eu/jaydee/api_server.git
synced 2026-09-17 02:12:55 +02:00
12 lines
391 B
Python
12 lines
391 B
Python
import os
|
|
from fastapi import HTTPException, Depends
|
|
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
|
|
|
security = HTTPBearer()
|
|
|
|
|
|
API_TOKEN = os.getenv("API_TOKEN", "mytoken")
|
|
|
|
def verify_token(credentials: HTTPAuthorizationCredentials = Depends(security)):
|
|
if credentials.credentials != API_TOKEN:
|
|
raise HTTPException(status_code=401, detail="Invalid token") |