Using Tools and Actions with Existing Authentication

Composio allows you to execute actions directly using existing authentication, in this guide weโ€™ll see how to star a repo on GitHub using GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER action and passing the Bearer token in the headers. You can get the connection paramateters of a connected account like the access token using SDK, learn more here

Use the add_auth method to add the existing authentication to the toolset for the app you want to use. in_ is where you want to add the auth, name is the name of the header you want to add and value is the value of the header.

from composio import ComposioToolSet, App

toolset = ComposioToolSet()

toolset.add_auth(
    app=App.GITHUB,
    parameters=[
        dict(
            name="Authorization",
            in_="header",
            value="Bearer gho_XL9IXXXXXX",
        )
    ],
)

toolset.execute_action(
    action="GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER",
    params={"owner": "composiohq", "repo": "composio"},
)