Merge pull request #755 from langflow-ai/keys-api-ux

keys api ux improvement
This commit is contained in:
Sebastián Estévez 2026-01-07 12:22:25 -05:00 committed by GitHub
commit 36d255704c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,6 +4,8 @@ API Key management endpoints.
These endpoints use JWT cookie authentication (for the UI) and allow users These endpoints use JWT cookie authentication (for the UI) and allow users
to create, list, and revoke their API keys for use with the public API. to create, list, and revoke their API keys for use with the public API.
""" """
import json
from starlette.requests import Request from starlette.requests import Request
from starlette.responses import JSONResponse from starlette.responses import JSONResponse
from utils.logging_config import get_logger from utils.logging_config import get_logger
@ -64,6 +66,17 @@ async def create_key_endpoint(request: Request, api_key_service):
try: try:
data = await request.json() data = await request.json()
except json.JSONDecodeError:
return JSONResponse(
{
"success": False,
"error": "Invalid or missing JSON body",
"example": {"name": "My API Key"},
},
status_code=400,
)
try:
name = data.get("name", "").strip() name = data.get("name", "").strip()
if not name: if not name: