See IAM delegated access Integrations Guide page for instructions to set up Cloud storage integrations. Using IAM delegated access integrations is the recommended option for all cloud users.

List your organization's IAM integrations

from labelbox import Client

client = Client("<YOUR_API_KEY>")
organization = client.get_organization()
iam_integrations = organization.get_iam_integrations()
for integration in iam_integrations:
    print(integration)
  
print("Default IAM integration:", organization.get_default_iam_integration())

Set IAM integration for Datasets

Each dataset can have only one IAM integration. Use the iam_integration optional field for client.create_dataset. If not set, it will use the default integration of your organization. You can specify another integration or set `iam_integration=None to not use delegated access.

You can then upload data rows with the cloud storage URLs.

iam_integration = organization.get_iam_integrations()[1] 
dataset = client.create_dataset(name="IAM manual demo", iam_integration=iam_integration)

Upload data rows with delegated access

Make sure the type of IAM integration is matching your data rows' cloud storage, then simply use the URL for the row_data field to upload data rows.

# Some examples: 
datarows = [{"row_data": "https://<bucket-name>.s3.<region>.amazonaws.com/<key>"}] # Amazon S3
datarows = [{"row_data": "gs://gcs-lb-demo-bucket/test.png"}] # Google Cloud Storage
datarows = [{"row_data": "https://labelboxdatasets.blob.core.windows.net/datasets/geospatial/001.jpg"}] # Microsoft Azure Blob Storage

task1 = dataset.create_data_rows(datarows)
task1.wait_till_done()