#!/usr/bin/env python3 """ 手动添加 API 到 Vaultwarden 用于测试加密是否正常 """ import requests import json import sys BASE_URL = "https://bit.180356.xyz" EMAIL = "1803560007@qq.com" MASTER_PASSWORD = "openclaw...." def get_token(): """获取访问令牌 - 尝试多种方式""" # 方式1: OAuth client_credentials (之前的方式) url = f"{BASE_URL}/identity/connect/token" data = { "grant_type": "client_credentials", "scope": "api", "client_id": "user.447f249d-4b82-4ccf-83fa-df8f45e2413a", "client_secret": "NMdyXUfkZiTzdVUamQOYG0QcFDNzdJ", "device_identifier": "openclaw-test", "device_type": "24", "device_name": "openclaw" } response = requests.post(url, data=data) if response.status_code == 200: return response.json().get("access_token") return None def create_item(token, name, username, password, notes=""): """创建条目""" headers = { "Authorization": f"Bearer {token}", "Content-Type": "application/json" } data = { "name": name, "notes": notes, "type": 1, # Login "favorite": False, "login": { "username": username, "password": password, "totp": None }, "fields": [], "collectionIds": [] } response = requests.post(f"{BASE_URL}/api/ciphers", headers=headers, json=data) return response.status_code in [200, 201] def main(): print("🔐 尝试获取访问令牌...") token = get_token() if not token: print("❌ 无法获取访问令牌") print("\n💡 请在网页上手动添加:") print("1. 打开 https://bit.180356.xyz") print("2. 登录: 1803560007@qq.com / openclaw....") print("3. 点击 + 新建项目") print("4. 手动添加:") print(" - GitHub PAT") print(" - Gitea Token") return print("✅ 获取令牌成功!") # 创建测试条目 test_items = [ ("GitHub PAT", "1803560007", "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", "测试条目"), ] for name, username, password, notes in test_items: if create_item(token, name, username, password, notes): print(f"✅ 创建成功: {name}") else: print(f"❌ 创建失败: {name}") if __name__ == "__main__": main()