$ cat node-template.py
L
Lark Get Task
// Fetches a single Lark task by its ID. Returns the task summary, status, due date, and members. Re-execute to refresh.
Input
Integration
template.py
1import os2import sys3import json4import traceback56try:7 import requests8except ImportError:9 import subprocess10 subprocess.check_call([sys.executable, "-m", "pip", "install", "requests"])11 import requests1213LARK_BASE_URL = "https://open.larksuite.com/open-apis"141516def get_lark_token():17 # Prefer user token (OAuth — sees user's resources)18 user_token = os.getenv("LARK_USER_TOKEN")19 if user_token:20 return user_token2122 # Fallback to tenant token (app-level — limited visibility)23 app_id = os.getenv("LARK_APP_ID")24 app_secret = os.getenv("LARK_APP_SECRET")25 if not app_id or not app_secret:26 raise ValueError(27 "Lark is not connected. Add LARK_APP_ID and LARK_APP_SECRET as workspace secrets, "28 "then connect via workspace settings to authorize user access."29 )30 resp = requests.post(31 f"{LARK_BASE_URL}/auth/v3/tenant_access_token/internal",32 json={"app_id": app_id, "app_secret": app_secret},33 )34 resp.raise_for_status()35 data = resp.json()36 if data.get("code") != 0:37 raise ValueError(f"Lark auth failed: {data.get('msg')}")38 return data["tenant_access_token"]394041def lark_request(method, path, **kwargs):42 token = get_lark_token()43 headers = {44 "Authorization": f"Bearer {token}",45 "Content-Type": "application/json; charset=utf-8",46 }47 resp = requests.request(48 method, f"{LARK_BASE_URL}{path}", headers=headers, **kwargs49 )50 resp.raise_for_status()51 data = resp.json()52 if data.get("code") != 0:53 raise ValueError(f"Lark API error ({data['code']}): {data.get('msg')}")54 return data555657def main():58 try:59 inputs = json.loads(sys.stdin.read()).get("inputs", {})6061 task_guid = inputs.get("taskGuid")62 if not task_guid:63 raise ValueError("taskGuid is required")6465 result = lark_request("GET", f"/task/v2/tasks/{task_guid}")6667 task = result.get("data", {}).get("task", {})6869 due_obj = task.get("due") or {}70 due_ts = due_obj.get("timestamp", "")71 members = task.get("members", [])72 status = "done" if task.get("completed_at") else "todo"7374 output = {75 "task": task,76 "summary": task.get("summary", ""),77 "status": status,78 "due": due_ts,79 "members": members,80 "success": True,81 }82 print(json.dumps(output, indent=2, ensure_ascii=False))8384 except Exception as e:85 error_output = {86 "error": str(e),87 "errorType": type(e).__name__,88 "traceback": traceback.format_exc(),89 }90 print(json.dumps(error_output), file=sys.stderr)91 sys.exit(1)929394if __name__ == "__main__":95 main()$ git log --oneline
v1.1.0
HEAD
2026-05-07v1.0.02026-04-09