https://linen.dev logo
i
Hey @abhishekpatil4 I'm working on white-labeling the Composio auth success screen and facing an issue during the token exchange step. After successful auth, I'm getting redirected to:
Copy code
https://app.affint.ai/integration/redirect?code=9163106406243.9280040381351.28602e78cc05d60de70a7e076e770aef382c03af4fc1f4cb8386b4ef6d282a05&state=production_ID%3AXeaBau7aMZ-D_apollo
I've already pointed the redirect (
app.affint.ai
) to:
Copy code
https://backend.composio.dev/api/v1/auth-apps/add
Can you help me understand how to exchange the code for an access token in this flow? I'm not sure if I'm missing a step or need to call a specific endpoint. Thanks in advance! 🙏
c
Hi Tauseef, You are successfully being redirected to your configured redirect Url which is pointing to
https://backend.composio.dev/api/v1/auth-apps/add
internally. After redirection, you should be able to complete the Auth flow, which will create a connection. You can now use this connected account to execute Tool calls. Let me know if this answers your query or if you are facing any Issues.
i
for user its showing initiated
c
Is the user able to complete the Auth flow?
i
after clicking on the accept button in the auth page, i am getting the above issue
c
Could you share a screen recording of the complete Auth Flow? It will help us understand the Issue.
i
yeah
do i need to create a separate backend to create redirect
as app.affint.ai is my main backend
c
No, you don't need to create a separate server to handle redirects. Your current redirect seems to be working fine. A screen recording of the complete flow will help us understand where the Issue lies exactly.
c
Could you retry? I noticed an auth consent screen in earlier attachments. Could you try to reproduce the Auth flow?
i
okay
getting same issue
if you want i can send you code snippet that i have used to exchance token
c
That's strange, Just to confirm—the image that you shared is a connection request made form same Integration? Yes, a code snippet will help! given your redirection is working fine(shared attachments) there could be an Issue with credentials.
i
yeah its from same
@app.get("/integration/redirect") async def handle_slack_redirect(request: Request): try: # Extract query parameters code = request.query_params.get("code") state = request.query_params.get("state") if not code or not state: return HTMLResponse(content="Missing code or state", status_code=400) # Exchange code for token via Composio async with httpx.AsyncClient() as client: response = await client.post("https://backend.composio.dev/api/v1/auth-apps/add", json={ "code": code, "state": state, "redirect_uri": "https://app.affint.ai/integration/redirect" }) if response.status_code == 200: # Token exchanged successfully return HTMLResponse(content="Integration successful!You may now close this tab.") else: return HTMLResponse( content=f"ErrorFailed to exchange code. Status: {response.status_code}{response.text}", status_code=response.status_code ) except Exception as e: return HTMLResponse(content=f"Server Error{str(e)}", status_code=500)
c
It looks like the Slack redirection is working, but you don't need to handle the exchange part, Composio does that for you. You can refer to this documentation: Let me know if this helps. FYI: I've shared the v3 version with you, here is [v1/v2](https://v1.docs.composio.dev/auth/white-labelling) if you need to refer it.
i
thanks
c
Sure, let me know if you face any Issues.
i
If you watch the video, you'll notice that the Composio URL appears for a few seconds right after connecting the tool or integration. How can we resolve this issue? Is there a solution, or do we need to create a custom OAuth direct login and pass a token to Composio for all tools? https://cdn.discordapp.com/attachments/1401210748100935763/1401274777687163051/Affint_-_The_AI_Office_Suite_-_Google_Chrome_2025-08-03_00-02-50.mp4?ex=688fae55&is=688e5cd5&hm=a920fedfe0f6379ae4df2ef0575f33d698f6ecae860c68811413f499191aeec7&
c
Yes, you can unshorten the URL to get the original URL. Here’s a snippet to unshorten it:
Copy code
import requests

def unshorten_url(short_url):
    response = requests.head(short_url, allow_redirects=True)
    return response.url

# Example usage:
print(unshorten_url('https://backend.composio.dev/api/v3/s/xxxxx'))
i
Thanks
2 Views