diff --git a/app/api/system.py b/app/api/system.py index eb46a86..04ef0d5 100644 --- a/app/api/system.py +++ b/app/api/system.py @@ -1,6 +1,4 @@ -from fastapi import APIRouter, HTTPException -import httpx -import json +from fastapi import APIRouter router = APIRouter() diff --git a/app/env.py b/app/env.py index 8afeac1..2d8044d 100644 --- a/app/env.py +++ b/app/env.py @@ -6,4 +6,6 @@ load_dotenv(dotenv_path=Path(__file__).parent.parent / ".env") CLIENT_NAME = os.getenv("CLIENT_NAME", "default-client-name") API_BASE = os.getenv("VRCHAT_API_BASE", "https://api.vrchat.cloud/api/1") TOKEN_FILE = Path(os.getenv("TOKEN_FILE", "data/auth/account.json")) -IS_RENDER = os.getenv("IS_RENDER", "false").lower() in ("true", "1", "t") \ No newline at end of file +IS_RENDER = os.getenv("IS_RENDER", "false").lower() in ("true", "1", "t") +ACCOUNT_URL_JSON = os.getenv("ACCOUNT_JSON_URL", "https://example.com/vrcapi_render_download_acc.php") +ACCOUNT_JSON_TOKEN = os.getenv("ACCOUNT_JSON_TOKEN", "your-token-here") \ No newline at end of file diff --git a/app/main.py b/app/main.py index 929bd02..1c7fa18 100644 --- a/app/main.py +++ b/app/main.py @@ -17,7 +17,7 @@ app = FastAPI( - Automatic token management with 2FA handling - Public and private VRChat data endpoints - Response caching for performance - - Easy deployment on self-hosted servers (YunoHost compatible) + - Easy deployment on hosted servers (Render compatible) Built with FastAPI and async HTTPX for high performance and reliability. """, diff --git a/app/prelaunch/vrchat_auth.py b/app/prelaunch/vrchat_auth.py index e20b0dc..58ef26d 100644 --- a/app/prelaunch/vrchat_auth.py +++ b/app/prelaunch/vrchat_auth.py @@ -6,10 +6,25 @@ import sys from pathlib import Path sys.path.append(str(Path(__file__).resolve().parent.parent)) -from env import CLIENT_NAME, API_BASE, TOKEN_FILE, IS_RENDER +from env import CLIENT_NAME, API_BASE, TOKEN_FILE, IS_RENDER, ACCOUNT_URL_JSON, ACCOUNT_JSON_TOKEN if IS_RENDER: - print("⚠️ Running in Render environment, skipping VRChat auth.") + import requests + print("⚠️ Running in Render environment, downloading account.json with token in URL...") + + url = f"{ACCOUNT_URL_JSON}?token={ACCOUNT_JSON_TOKEN}" + + try: + response = requests.get(url) + response.raise_for_status() + except requests.RequestException as e: + print(f"❌ Failed to download account.json: {e}") + sys.exit(1) + + with open("data/auth/account.json", "wb") as f: + f.write(response.content) + + print("✅ account.json downloaded successfully.") sys.exit(0) def save_token(data): diff --git a/vrcapi_render_download_acc.php b/vrcapi_render_download_acc.php new file mode 100644 index 0000000..c414ae1 --- /dev/null +++ b/vrcapi_render_download_acc.php @@ -0,0 +1,24 @@ + 'Unauthorized']); + exit; +} + +$jsonContent = <<<'JSON' +{ + "manual_username": "user123", + "displayName": "User Display Name", + "user_id": "abcdef123456", + "auth": "xxxxxxxxxxxxxxx==", + "auth_cookie": "yyyyyyyyyyyyyy", + "created_at": "2025-06-22T14:00:00+00:00" +} +JSON; + +header('Content-Type: application/json'); +echo $jsonContent; + +?> \ No newline at end of file