Cloudflare Stream API - Authentication error

Hi,

Im trying to call the /stream/direct_upload endpoint of the Cloudflare Stream API (from Firebase Cloud Function) to get a signed url for a video upload.

This is the code for the post request:

 const url = `https://api.cloudflare.com/client/v4/accounts/${cloudflare.accountId}/stream/direct_upload`;
const cloudflareResponse = await axios.post(
      url,
      {
        maxDurationSeconds: 60,
      },
      {
        headers: {
          Authorization: `Bearer ${cloudflare.apiKey}`,
          "Content-Type": "application/json",
        },
      }
    );

I’ve tripple checked the accountId and the apiKey.
Im using the account id from Dashboard → Stream → Videos → Account Details → Account ID
and the api key is Profile → API Tokens → Global API Key

And still keep on getting the { code: 10000, message: 'Authentication error' }.

Im running out of ideas…Help is much appreciated!

Note: I just upgraded to Cloudflare Stream today and also tried logging out and in again.

That format requires an API token, not the API key.

3 Likes

Thx so much! I have had created a Custom Token with Stream editing rights before that somehow didn’t work, but when I used this default template to create the token it worked finally! :raised_hands:

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.