Spaces:
Sleeping
Sleeping
Download src/auth.py from precove/fclip_back4: direct link, hf CLI and curl.
- Browser
- Download file 541 Bytes
-
https://huggingface.co/spaces/precove/fclip_back4/resolve/main/src/auth.py
- Command line
-
hf download hf://spaces/precove/fclip_back4/src/auth.py
-
curl -L -o auth.py https://huggingface.co/spaces/precove/fclip_back4/resolve/main/src/auth.py
541 Bytes
| from fastapi import HTTPException, Security | |
| from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials | |
| from decouple import config | |
| API_TOKEN = config("API_TOKEN") | |
| security = HTTPBearer() | |
| def verify_token(credentials: HTTPAuthorizationCredentials = Security(security)): | |
| if credentials.credentials != API_TOKEN: | |
| raise HTTPException( | |
| status_code=401, | |
| detail="Invalid authentication credentials", | |
| headers={"WWW-Authenticate": "Bearer"}, | |
| ) | |
| return credentials.credentials | |