MCPcopy Create free account
hub / github.com/TheSmallHanCat/flow2api / verify_api_key_flexible

Function verify_api_key_flexible

src/core/auth.py:44–62  ·  view source on GitHub ↗

Verify API key from Authorization header, x-goog-api-key header, or key query param.

(
    credentials: Optional[HTTPAuthorizationCredentials] = Security(optional_security),
    x_goog_api_key: Optional[str] = Header(None, alias="x-goog-api-key"),
    key: Optional[str] = Query(None),
)

Source from the content-addressed store, hash-verified

42
43
44async def verify_api_key_flexible(
45 credentials: Optional[HTTPAuthorizationCredentials] = Security(optional_security),
46 x_goog_api_key: Optional[str] = Header(None, alias="x-goog-api-key"),
47 key: Optional[str] = Query(None),
48) -> str:
49 """Verify API key from Authorization header, x-goog-api-key header, or key query param."""
50 api_key = None
51
52 if credentials is not None:
53 api_key = credentials.credentials
54 elif x_goog_api_key:
55 api_key = x_goog_api_key
56 elif key:
57 api_key = key
58
59 if not api_key or not AuthManager.verify_api_key(api_key):
60 raise HTTPException(status_code=401, detail="Invalid API key")
61
62 return api_key

Callers

nothing calls this directly

Calls 1

verify_api_keyMethod · 0.80

Tested by

no test coverage detected