Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | from composio import Composio |
| 2 | |
| 3 | composio = Composio() |
| 4 | |
| 5 | # List all auth configs |
| 6 | auth_configs = composio.auth_configs.list() |
| 7 | print(auth_configs) |
| 8 | |
| 9 | # Use composio managed auth |
| 10 | auth_config = composio.auth_configs.create( |
| 11 | toolkit="github", |
| 12 | options={ |
| 13 | "type": "use_composio_managed_auth", |
| 14 | }, |
| 15 | ) |
| 16 | print(auth_config) |
| 17 | |
| 18 | # Use custom auth |
| 19 | auth_config = composio.auth_configs.create( # type: ignore[call-overload] # credentials TypedDict omits client_id/client_secret/oauth_redirect_uri; API accepts them |
| 20 | toolkit="notion", |
| 21 | options={ |
| 22 | "name": "Notion Auth", |
| 23 | "type": "use_custom_auth", |
| 24 | "auth_scheme": "OAUTH2", |
| 25 | "credentials": { |
| 26 | "client_id": "1234567890", |
| 27 | "client_secret": "1234567890", |
| 28 | "oauth_redirect_uri": "https://backend.composio.dev/api/v3/toolkits/auth/callback", |
| 29 | }, |
| 30 | }, |
| 31 | ) |
| 32 | print(auth_config) |
| 33 | |
| 34 | # When creating an auth config, you can check for required fields |
| 35 | required_fields = composio.toolkits.get_auth_config_creation_fields( |
| 36 | toolkit="NOTION", |
| 37 | auth_scheme="OAUTH2", |
| 38 | ) |
| 39 | print(required_fields) |
| 40 | |
| 41 | # Retrieve a specific auth config |
| 42 | auth_config_retrieved = composio.auth_configs.get(auth_config.id) |
| 43 | print(auth_config_retrieved) |
| 44 | |
| 45 | # Fetch required input fields for auth config |
| 46 | toolkit = composio.toolkits.get(slug="notion") |
| 47 | required_input_fields = [ |
| 48 | field.name for field in toolkit.auth_config_details or [] if field.mode |
| 49 | ] |
| 50 | print(required_input_fields) |
| 51 | |
| 52 | # Update an auth config |
| 53 | auth_config_updated = composio.auth_configs.update( # type: ignore[call-overload] # credentials TypedDict omits client_id/client_secret, which the API accepts |
| 54 | auth_config.id, |
| 55 | options={ |
| 56 | "type": "custom", |
| 57 | "credentials": { |
| 58 | "client_id": "1234567890", |
| 59 | "client_secret": "1234567890", |
| 60 | }, |
| 61 | "tool_access_config": { |
| 62 | "tools_for_connected_account_creation": ["NOTION_ADD_PAGE_CONTENT"], |
| 63 | }, |
| 64 | }, |
| 65 | ) |
| 66 | print(auth_config_updated) |
| 67 | |
| 68 | # Enable an auth config |
| 69 | composio.auth_configs.enable(auth_config.id) |
| 70 | print("Auth config enabled") |
| 71 | |
| 72 | # Disable an auth config |
| 73 | composio.auth_configs.disable(auth_config.id) |
| 74 | print("Auth config disabled") |
| 75 | |
| 76 | # Delete an auth config |
| 77 | composio.auth_configs.delete(auth_config.id) |
| 78 | print("Auth config deleted") |