mirror of
https://github.com/ComposioHQ/composio.git
synced 2026-09-22 11:46:35 +08:00
8086ef02cb
## Summary - Repairs runnable TypeScript and Python examples for current backend requirements, including authenticated MCP endpoints, current transports, valid tool identifiers, provider limits, and resource uniqueness. - Replaces placeholder resource IDs with explicit `COMPOSIO_EXAMPLES_*` configuration and makes failed examples exit loudly. - Adds `scripts/examples-provision.mjs` as an idempotent provisioning check for a disposable examples project. ## Scope - This PR no longer changes the Python SDK runtime or generated-client dependency. - Python remains pinned to the published `composio-client==1.43.0` in `pyproject.toml`, `setup.py`, and `uv.lock`. - The owned 2.x client integration is deferred until that client completes its release guarantees and is explicitly published. - The scheduled live workflow and manifest remain deferred until their runner is tracked. ## Verification - `make chk` - `make tst` (`927 passed, 33 skipped`) - Hosted checks rerun against commit `12691aca7`.
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
import os
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.responses import RedirectResponse
|
|
|
|
from composio import Composio
|
|
|
|
# Create a FastAPI app
|
|
app = FastAPI()
|
|
|
|
# Create a Composio client
|
|
composio = Composio()
|
|
|
|
|
|
@app.get("/authorize/{toolkit}")
|
|
def authorize_app(toolkit: str):
|
|
# retrieve the user id from your app
|
|
user_id = os.environ.get("COMPOSIO_EXAMPLES_USER_ID", "")
|
|
|
|
# retrieve the auth config id from your app
|
|
auth_config_id = os.environ.get("COMPOSIO_EXAMPLES_GMAIL_AUTH_CONFIG_ID", "")
|
|
|
|
# initiate the connection request
|
|
connection_request = composio.connected_accounts.initiate(
|
|
user_id=user_id,
|
|
auth_config_id=auth_config_id,
|
|
)
|
|
return RedirectResponse(url=connection_request.redirect_url) # type: ignore
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
|
|
for var in ("COMPOSIO_EXAMPLES_USER_ID", "COMPOSIO_EXAMPLES_GMAIL_AUTH_CONFIG_ID"):
|
|
if not os.environ.get(var):
|
|
raise SystemExit(f"{var} is required")
|
|
|
|
# Fail fast on bad credentials or a stale auth config before serving requests
|
|
composio.auth_configs.get(os.environ["COMPOSIO_EXAMPLES_GMAIL_AUTH_CONFIG_ID"])
|
|
|
|
uvicorn.run(app, host="127.0.0.1", port=8000)
|