SDK Language
TypeScript / Node.js SDK (@composio/core)
SDK Version
N/A — calling Composio REST API v3 directly (no SDK): POST /api/v3/auth_configs and POST /api/v3/connected_accounts/link
Runtime Environment
Node.js v26 on macOS (server calls Composio REST via fetch)
Environment
Local Development
Describe the Bug
Connecting a custom-auth (OAUTH2) account for the tiktok toolkit fails at the token-exchange step, immediately after a successful user consent. TikTok is not Composio-managed (COMPOSIO_MANAGE_CONNECTIONS returns "Composio does not manage auth for toolkit tiktok"), so use_custom_auth is the only option.
After the user approves the TikTok consent screen (all requested scopes shown correctly), the callback fails with:
Failed to connect Composio to Tiktok
Invalid OAuth2 token exchange response:
[{ "code": "invalid_type", "expected": "string", "received": "undefined",
"path": ["access_token"], "message": "Required" }]
TikTok's token endpoint returns no access_token, so Composio's response validation fails. Reproduces identically every attempt.
Likely cause: TikTok's OAuth is non-standard — its token endpoint (https://open.tiktokapis.com/v2/oauth/token/) requires client_key (NOT the standard client_id) and returns access_token at the top level. It looks like the custom-auth OAUTH2 flow posts client_id, so TikTok returns an error object (no token) and the parser then fails on the missing access_token.
Steps to Reproduce
- Create a custom-auth config for TikTok: POST /api/v3/auth_configs with
{ toolkit: { slug: "tiktok" }, auth_config: { type: "use_custom_auth", authScheme: "OAUTH2", name: "...", credentials: { client_id, client_secret, scopes: "user.info.basic,user.info.profile,user.info.stats,video.list", oauth_redirect_uri: "https://backend.composio.dev/api/v3.1/toolkits/auth/callback" } } } (own TikTok dev app; redirect URI registered on the app; sandbox with the account added as a target user).
- Initiate the connection: POST /api/v3/connected_accounts/link with
{ auth_config_id, user_id } and open the returned redirect_url.
- Approve the TikTok consent screen (all 4 scopes are shown correctly).
- Observe the callback fail with the "Invalid OAuth2 token exchange response ... access_token Required" error above.
Expected: the connection completes and TIKTOK_GET_USER_STATS / TIKTOK_LIST_VIDEOS become callable for the user.
Actual: token exchange fails; no connected account is created.
Minimal Reproducible Example
# 1) Create custom-auth config (TikTok is not Composio-managed)
curl -X POST https://backend.composio.dev/api/v3/auth_configs \
-H "x-api-key: $COMPOSIO_API_KEY" -H "Content-Type: application/json" \
-d '{"toolkit":{"slug":"tiktok"},"auth_config":{"type":"use_custom_auth","authScheme":"OAUTH2","name":"TikTok","credentials":{"client_id":"<tiktok_client_key>","client_secret":"<secret>","scopes":"user.info.basic,user.info.profile,user.info.stats,video.list","oauth_redirect_uri":"https://backend.composio.dev/api/v3.1/toolkits/auth/callback"}}}'
# -> 201, returns auth_config id ac_xxx
# 2) Initiate connection, then open redirect_url and approve TikTok consent
curl -X POST https://backend.composio.dev/api/v3/connected_accounts/link \
-H "x-api-key: $COMPOSIO_API_KEY" -H "Content-Type: application/json" \
-d '{"auth_config_id":"ac_xxx","user_id":"default"}'
# -> 201, returns redirect_url -> approve -> callback fails at token exchange
Error Output / Stack Trace
Shown on the Composio connect callback page after approving the TikTok consent:
Failed to connect Composio to Tiktok
We couldn't connect your Tiktok account to Composio. Please try again.
Invalid OAuth2 token exchange response: [ { "code": "invalid_type", "expected": "string", "received": "undefined", "path": [ "access_token" ], "message": "Required" } ]
Reproducibility
Additional Context or Screenshots
- The consent screen renders correctly with the right app name and all requested scopes, so the authorize step is fine — only the server-side token exchange fails.
- Scopes requested:
user.info.basic, user.info.profile, user.info.stats, video.list.
- Happy to share the
auth_config id and TikTok client key privately to help reproduce (omitting them here). No SDK involved — calling the REST API directly.
SDK Language
TypeScript / Node.js SDK (
@composio/core)SDK Version
N/A — calling Composio REST API v3 directly (no SDK): POST /api/v3/auth_configs and POST /api/v3/connected_accounts/link
Runtime Environment
Node.js v26 on macOS (server calls Composio REST via fetch)
Environment
Local Development
Describe the Bug
Connecting a custom-auth (OAUTH2) account for the
tiktoktoolkit fails at the token-exchange step, immediately after a successful user consent. TikTok is not Composio-managed (COMPOSIO_MANAGE_CONNECTIONS returns "Composio does not manage auth for toolkit tiktok"), souse_custom_authis the only option.After the user approves the TikTok consent screen (all requested scopes shown correctly), the callback fails with:
TikTok's token endpoint returns no
access_token, so Composio's response validation fails. Reproduces identically every attempt.Likely cause: TikTok's OAuth is non-standard — its token endpoint (
https://open.tiktokapis.com/v2/oauth/token/) requiresclient_key(NOT the standardclient_id) and returnsaccess_tokenat the top level. It looks like the custom-auth OAUTH2 flow postsclient_id, so TikTok returns an error object (no token) and the parser then fails on the missingaccess_token.Steps to Reproduce
{ toolkit: { slug: "tiktok" }, auth_config: { type: "use_custom_auth", authScheme: "OAUTH2", name: "...", credentials: { client_id, client_secret, scopes: "user.info.basic,user.info.profile,user.info.stats,video.list", oauth_redirect_uri: "https://backend.composio.dev/api/v3.1/toolkits/auth/callback" } } }(own TikTok dev app; redirect URI registered on the app; sandbox with the account added as a target user).{ auth_config_id, user_id }and open the returnedredirect_url.Expected: the connection completes and
TIKTOK_GET_USER_STATS/TIKTOK_LIST_VIDEOSbecome callable for the user.Actual: token exchange fails; no connected account is created.
Minimal Reproducible Example
Error Output / Stack Trace
Reproducibility
Additional Context or Screenshots
user.info.basic,user.info.profile,user.info.stats,video.list.auth_configid and TikTok client key privately to help reproduce (omitting them here). No SDK involved — calling the REST API directly.