[Solved ✅] How to use tools with Auth with CrewAI?
I have been trying to use tools like Spotify and Twitter with CrewAI, the connection process seems to be successful, however the tools doesn't seem to work when given to the agent. So could you please guide me as to how to put it all together. Here's the code:
from crewai import Agent, Task, Crew, LLM
from langchain_groq import ChatGroq
from composio_crewai import ComposioToolSet, Action, App
import os
toolset = ComposioToolSet(
api_key="my-api", entity_id="default")
tools = toolset.get_tools(actions=['SPOTIFY_GET_USER_S_TOP_ARTISTS'])
groq_api_key = os.getenv("GROQ_API_KEY")
llm = LLM(
model="llama-3.1-70b-versatile",
api_key=groq_api_key,
base_url="https://api.groq.com/openai/v1"
)
Define agent
crewai_agent = Agent(
role="Spotify Analyser",
goal="""You analyse spotify accounts.""",
backstory=(
"You work as an analyst in Spotify and understand user behavior and patterns."
),
verbose=True,
tools=tools,
llm=llm,
)
task = Task(
description="Give the user's top spotify artists.",
agent=crewai_agent,
expected_output="User's top spotify artists in markdown."
)
my_crew = Crew(agents=[crewai_agent], tasks=[task])
result = my_crew.kickoff()
print(result)
6 Replies
other-emerald•2mo ago
What error are you getting??
Also use
Action
enum to get the required actionsratty-blushOP•2mo ago
i did establish the connection based on how it was given in the docs but the agents are not able to use the tool.

ratty-blushOP•2mo ago
by using the action enum you mean this: "actions=['SPOTIFY_GET_USER_S_TOP_ARTISTS'])"?
foreign-sapphire•2mo ago
Hey @epitisia, Spotify has made changes to its APIs. Now, access to certain features requires approved developer OAuth2 credentials. You can use these creds and create a new integration, ref: https://docs.composio.dev/patterns/Auth/Integrations#using-your-own-oauth-developer-app
Composio Docs
How To Configure Connections? - Composio
Composio enables your agents to connect with Various Tools and work with them
ratty-blushOP•2mo ago
so after configuring the connection i can just go ahead with the code i pasted above?
other-emerald•2mo ago
Yes it should, try it once and lemme know if it works or not.