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
genetic-orange•2w ago
Checking @xaxbxc_
genetic-orange•2w ago
@thatsmeadarsh I currently have no existing SerpApi connection, so the code should generate one. Instead, I'm getting the mentioned error.
genetic-orange•2w ago
Yea yea I got it, I am seeing it and letting you know
genetic-orange•2w ago
@thatsmeadarsh Thanks!
What's the status on this?
genetic-orange•2w ago
I have shared the issue with the team letting you know asap with the status
genetic-orange•2w 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.
correct-apricot•2w 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.genetic-orange•2w 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:
correct-apricot•2w ago
What's your email id?
genetic-orange•2w ago
Is the email ID required or what do you mean?
correct-apricot•2w ago
No, just want to check the logs.
The email id you registered with on Composio.
genetic-orange•2w ago
Where do I get it?
correct-apricot•2w ago
On your profile pix
correct-apricot•2w 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
.genetic-orange•2w ago
@kaavee Thanks, it works!