SignatureError: "Failed to sign request"
Your script stops with SignatureError: Failed to sign request: ... status code 404; URL: https://webcast.tiktok.com/webcast/im/fetch/ (TikTok-Live-Connector 1.x), or with "Failed to sign a request" (SignatureMissingTokensError) in the 2.x line.
The error
SignatureError: Failed to sign request: ... status code 404; URL: https://webcast.tiktok.com/webcast/im/fetch/
# TikTok-Live-Connector 2.x wording
SignatureMissingTokensError: Failed to sign a requestWhat it means
Before connecting, the library sends the TikTok URL it wants to open to a sign service and expects a signed version back. "Failed to sign request" means that call failed (the status code in the message tells you how) or came back without the tokens the library needs.
The exact wording "Failed to sign request: ...; URL: ..." comes from the 1.x line (WebcastPushConnection). Its last release is 1.2.3 from January 2025, so it does not follow later changes on the TikTok side.
Fix it in the library
- Check your version:
npm ls tiktok-live-connector. If it is 1.x, move to 2.x:npm install tiktok-live-connector@latest. The class is nowTikTokLiveConnectionand events useWebcastEventconstants; the README has the full example. - On 2.x, read the full message: the status code shows whether the key was rejected, the rate limit was hit or the service was unavailable. Pass your sign service key with
signApiKeyif you have one. - Retry with a backoff instead of a tight loop, and check the issue tracker for an open report with the same status code (for example issue #327).
Or use the hosted API
If you would rather not track sign service changes yourself, the TikTools SDK connects with your API key and delivers the same events as JSON.
npm install @tiktool/live// Before: const { TikTokLiveConnection } = require('tiktok-live-connector');
const { TikTokLive } = require('@tiktool/live');
const connection = new TikTokLive({
uniqueId: process.argv[2] || 'username',
apiKey: process.env.TIKTOOL_API_KEY || 'YOUR_API_KEY',
});
connection.on('connected', () => console.log(`Connected to roomId ${connection.roomId}`));
connection.on('chat', data => console.log(`${data.user.uniqueId} (userId:${data.user.id}) writes: ${data.comment}`));
connection.on('gift', data => {
if (data.giftType === 1 && !data.repeatEnd) return; // streak still running
console.log(`${data.user.uniqueId} sent ${data.giftName} x${data.repeatCount} (${data.diamondCount * data.repeatCount} diamonds)`);
});
connection.on('like', data => console.log(`${data.user.uniqueId} liked x${data.likeCount} (total ${data.totalLikes})`));
connection.on('member', data => console.log(`${data.user.uniqueId} joined`));
connection.on('roomUserSeq', data => console.log(`Viewers: ${data.viewerCount}`));
connection.on('disconnected', (code, reason) => console.log(`Disconnected ${code} ${reason}`));
connection.connect().catch(err => console.error('Failed to connect', err)); Python: pip install tiktok-live-api. Side-by-side code for both languages and the full event name map are in the migration guide. Plans and connection limits are on the pricing page; Sandbox is a 7-day evaluation, no credit card.