Spaces:
Runtime error
Runtime error
Add reset_key.py utility
Browse files123456789101112131415161718192021222324252627282930313233343536import osimport sysfrom werkzeug.security import generate_password_hashfrom sqlalchemy.orm import Sessionimport database as db
# Force local SQLiteos.environ["DATABASE_URL"] = "sqlite:///./data/users.db"
def reset_local_key(): print("🔄 Resetting API Key for 'LocalClient'...") # Setup DB database = db.SessionLocal() # Find Client client = db.get_api_client_by_name(database, "LocalClient") if not client: print("❌ 'LocalClient' not found! Did you run ingestion?") return # Generate New Key import secrets new_key = f"nbk_local_{secrets.token_hex(16)}" hashed_key = generate_password_hash(new_key) # Update DB client.hashed_api_key = hashed_key database.commit() print(f"\n✅ Success! New API Key for LocalClient:") print(f"👉 {new_key}") print("\n(Copy this key now, you won't see it again!)")
if __name__ == "__main__": reset_local_key()reset_key.pyAdded+36