diff --git a/studio/backend/auth/storage.py b/studio/backend/auth/storage.py index 9456f7fea5..0c4a995c5b 100644 --- a/studio/backend/auth/storage.py +++ b/studio/backend/auth/storage.py @@ -393,7 +393,7 @@ def create_api_key( """ raw_key = API_KEY_PREFIX + secrets.token_hex(16) key_hash = _hash_token(raw_key) - key_prefix = raw_key[len(API_KEY_PREFIX): len(API_KEY_PREFIX) + 8] + key_prefix = raw_key[len(API_KEY_PREFIX) : len(API_KEY_PREFIX) + 8] now = datetime.now(timezone.utc).isoformat() conn = get_connection() @@ -406,9 +406,7 @@ def create_api_key( (username, key_prefix, key_hash, name, now, expires_at), ) conn.commit() - cur = conn.execute( - "SELECT * FROM api_keys WHERE key_hash = ?", (key_hash,) - ) + cur = conn.execute("SELECT * FROM api_keys WHERE key_hash = ?", (key_hash,)) row = cur.fetchone() return raw_key, dict(row) finally: diff --git a/studio/backend/models/auth.py b/studio/backend/models/auth.py index d6d63b3485..c55e646508 100644 --- a/studio/backend/models/auth.py +++ b/studio/backend/models/auth.py @@ -68,7 +68,9 @@ class ApiKeyResponse(BaseModel): id: int name: str - key_prefix: str = Field(..., description = "First 8 characters after sk-unsloth- for display") + key_prefix: str = Field( + ..., description = "First 8 characters after sk-unsloth- for display" + ) created_at: str last_used_at: Optional[str] = None expires_at: Optional[str] = None