[Solved ✅] Problems with programatically connecting an account
I want to programatically connect an account. I know this can be done with
composio add <account>
, but I want to do this programatically.
I have the following code:
I get the following error in the browser when viewing the Streamlit app:
What's wrong with my code? The error message doesn't tell me much.15 Replies
metropolitan-bronze•6mo ago
Checking @xaxbxc_
flat-fuchsiaOP•6mo ago
@thatsmeadarsh I currently have no existing SerpApi connection, so the code should generate one. Instead, I'm getting the mentioned error.
metropolitan-bronze•6mo ago
Yea yea I got it, I am seeing it and letting you know
flat-fuchsiaOP•6mo ago
@thatsmeadarsh Thanks!
What's the status on this?
metropolitan-bronze•6mo ago
I have shared the issue with the team letting you know asap with the status
flat-fuchsiaOP•6mo ago
@thatsmeadarsh Sorry for being a bit pushy, but I want to use Composio for a hackathon. So, I'm in a hurry, and I don't want to ditch Composio.
modern-teal•6mo ago
@xaxbxc_ Looking into it.
Can you try this one?
Otherwise, let's get on a quick call?
Found the issue, fixing it.
Please run
pip install -U composio-crewai
to install composio-crewai==0.5.17
And change the api_key
code to API_KEY
as auth mode. This should fix the issue.flat-fuchsiaOP•6mo ago
@kaavee Yessssssss, it's working now. Thanks!
@kaavee I'm getting an invalid API SerpApi key error, although it should be valid.
The API key in the Composio "Connected account" dashboard is identical to the one in the SerpApi dashboard.
@kaavee If I use the Composio dashboard to connect SerpApi and provide the API key there, the code doesn't throw the error.
Did I do anything wrong when passing the API key programatically?
@thatsmeadarsh
I figured out what's the problem. If I do it programatically, the API key is not passed in the Headers (I see
{"api_key":""}
), although the "API KEY" above is valid. I should see {"api_key":"xxxxxxxxxxxxxxxxxxxxx"}
.
Whereas if I do it using the Composio dashboard, I see {"api_key":"xxxxxxxxxxxxxxxxxxxxx"}
and the code works.
Why is that?
@thatsmeadarsh @kaavee I think something is wrong on your side since I see the API key if I print it using st.write()
as follows:
modern-teal•6mo ago
What's your email id?
flat-fuchsiaOP•6mo ago
Is the email ID required or what do you mean?
modern-teal•6mo ago
No, just want to check the logs.
The email id you registered with on Composio.
flat-fuchsiaOP•6mo ago
Where do I get it?
modern-teal•6mo ago
On your profile pix

modern-teal•6mo ago
You need to change the code to
auth_config = {"apikey": serpapi_api_key}
api_key -> apikey
To get which field to be filled for future, use:
app = composio_client.client.apps.get(name=str(App.SERPAPI))
Output
Here the field name is apikey
.flat-fuchsiaOP•6mo ago
@kaavee Thanks, it works!