admin管理员组文章数量:1123704
Title:
Cloudflare Stream API: 403 Forbidden When Fetching Recorded Videos for Live Input
Body:
I have created a new live stream using the Cloudflare SDK, streamed video using OBS (RTMPS), and successfully recorded a 3–4 minute video. I can see the recorded videos on the Cloudflare dashboard. However, when trying to fetch the recorded video IDs via the API, I encounter a 403 Forbidden
error.
What I Tried:
I referred to the Cloudflare Stream Docs - Record and Replay and implemented the following API request since there is no SDK support for this specific endpoint:
Here is my code:
typescript
async getSinglestream(id: string) {
try {
const url = `/${this.accountid}/stream/live_inputs/${id}/videos`;
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: `Bearer ${this.configService.get<string>('cldflaretoken')}`, // API token
},
});
console.log(this.accountid);
console.log(this.configService.get<string>('cldflaretoken'));
console.log(response);
if (!response.ok) {
const error = await response.json();
throw new Error(`Failed to fetch videos: ${error.errors || response.statusText}`);
}
const data = await response.json();
return data.result; // `result` contains the videos array in Cloudflare's API response
}catch (error) {
console.error('Error fetching video recordings:', error.message);
throw new Error('Failed to fetch video recordings for the live input');
}
}
The Error I Encounter:
The response object indicates a 403 Forbidden
error. Below is the response log:
Response {
status: 403,
statusText: ‘Forbidden’,
headers: Headers {
date: ‘Thu, 09 Jan 2025 08:47:41 GMT’,
‘content-type’: ‘text/html; charset=UTF-8’,
...
},
body: ReadableStream { ... },
bodyUsed: false,
ok: false,
redirected: false,
type: ‘basic’,
url: ‘’
}
Error fetching video recordings: Unexpected token '<', "<!DOCTYPE "… is not valid JSON
What I Verified:
- The credentials (
accountId
andAPI token
) are correct because I used the same credentials to successfully create the live stream. - I confirmed the recorded video exists on the Cloudflare dashboard for the given
LIVE_INPUT_UID
.
Expected Result:
I expect a successful API response with the list of recorded videos in JSON format, as described in the Cloudflare API documentation:
bash curl -X GET \ -H "Authorization: Bearer <API_TOKEN>" \ /<ACCOUNT_ID>/stream/live_inputs/<LIVE_INPUT_UID> /videos
版权声明:本文标题:how to get the recorded stream details via api or sdk from cloudflare stream api not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736589861a1945060.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论