"Error message" : "An authentication token is required to complete this operation."



I am currently trying to export annotated data in JSON format, but although the JSON file itself is exported, the annotated object information is not reflected.
So, when I step on the URL listed in the “frames” line, the following error message is displayed.

{"status":"error","message":"An authentication token is required to complete this operation. The Authorization header must contain your API key."}

Do you know the cause and solution for these?

Implementation Procedure

I did the following before I got the error message

1. Creating an API Key

I created an API key from the labelbox UI account setup form.

2. Annotation

Bounding boxes have been added for videos. The following image shows the Labelbox labeling edit page.

3. Annotation

I ran the script for exporting for video as described in the documentation.

from labelbox import Client, Project
from matplotlib import pyplot as plt
from IPython.display import clear_output
import numpy as np
import json
import ndjson
import requests
import cv2
from typing import Dict, Any
import os

PROJECT_ID = "<My project ID>"
API_KEY = "<My API Key>"
client = Client(api_key=API_KEY)

export_url = project.export_labels()


If the behavior is as described in the documentation, this output should show the annotation object information in JSON format. However, the “label” entry in my output is as follows:

 'Label': {'classifications': [],
  'frames': '<frame_link>',
  'objects': [],
  'relationships': []},

Then, when I clicked on the <frame_link>, I received the following error message


Thanks for the detailed post and question! You’re just missing one final step to be able to grab the URL for the labels on the individual frames of the video, and can do so by following the steps shown here:

# Grab the annotations url
annotations_url = exports[0]["Label"]["frames"]

# Provide the appropriate authorization to view the labeled frames
headers = {"Authorization": f"Bearer {API_KEY}"}
annotations = ndjson.loads(requests.get(annotations_url, headers=headers).text)

# Make the data easy to lookup by assigning each frame its frame number
annotations = {annot["frameNumber"]: annot for annot in annotations}

# Grab the first frame and print the contents
first_frame = annotations[1]
print(json.dumps(first_frame, indent=2))

The code displayed here is just a few cells down in the Google Colab that you linked as well as in the documentation, so you were completely on the right path! The nuance here is that before accessing the frames URL, you must once more provide authorization using your API Key.

If you wish to access the frames without using Python, I would advise you to check out the instructions for using Postman, which are at the bottom of the docs page linked above in your post and mine.

Thanks again for the posting!

Hello, Thank you for answering my question so thoughtfully!

I see, I had an item for API authentication in the script, but I missed it.

I ran it as advised, and it outputs the annotation info in JSON format with no problems!

  "frameNumber": 10,
  "classifications": [],
  "objects": [
      "featureId": "cl2y2itha00033g6co8mjm5fr",
      "schemaId": "cl2tfrhrd0w1u079w8j0v1acm",
      "title": "0_6",
      "value": "0_6",
      "color": "#A30059",
      "keyframe": false,
      "bbox": {
        "top": 660.833,
        "left": 3583.667,
        "height": 78.5,
        "width": 32
      "classifications": []
      "featureId": "cl2y2j1tr00073g6cev7sio8s",
      "schemaId": "cl2tfrhre0w2m079w1jaeb5ue",
      "title": "1_20",
      "value": "1_20",
      "color": "#3B5DFF",
      "keyframe": false,
      "bbox": {
        "top": 561.556,
        "left": 3462.222,
        "height": 44.889,
        "width": 26
      "classifications": []

I will consider outputting using POSTMAN since the annotator cannot use Python.
Thank you very much!