Box Storage
Load data from Box Storage.
Configure via UI
We can load data from Box using one of two different types of authentication, either a Developer Token or a Client Credential Grant.
1. Developer Token Authentication Mechanism
Developer Tokens are short lived and can be created in the Box Developer Console.
2. Client Credential Grant Authentication Mechanism
These credentials can be used to access Box data for a specific user or an entire enterprise and are longer-lived than Developer Tokens. You can use either an Enterprise ID or a User ID to authenticate.
Setting up Box CCG Credentials
- Log in to your Box account / Create a Box developer account and navigate to the developer console.
- Create a new custom app.
- Select "Server Authentication (Client Credentials Grant)" as the authentication method.
- Under "App Access Level", select
App + Enterprise Access
. - We recommend giving your app all permissions, as shown:
- Save your changes and submit the app for authorization.
- Open the Box Admin console. As an admin, authorize the app in the Custom Apps Manager.
- Once the app is enabled, get your
User ID
,Enterprise ID
,Client ID
andClient Secret
from app console in developer console.
1. Client Credential Grant Authentication Mechanism using an Enterprise ID
Note that to access files via an Enterprise ID, they need to have been shared with that app. You can share files with an app by its email address, which can be found in the Developer Console under "Service Account Info".
2. Client Credential Grant Authentication Mechanism using a User ID
If you are using a User ID, you can access files that have been shared with or created by that user. This will be the user ID of the person who created the app.
Configure via API / Client
1. Developer Token Authentication Mechanism
- Python Client
- TypeScript Client
from llama_cloud.types import CloudBoxDataSource
ds = {
'name': '<your-name>',
'source_type': 'BOX',
'component': CloudBoxDataSource(
folder_id='<folder_id>', # Optional
developer_token='<token>', # Developer Tokens are short lived
)
}
data_source = client.data_sources.create_data_source(request=ds)
const ds = {
'name': '<your-name>',
'sourceType': 'BOX',
'component': {
'folder_id'='<folder_id>', // Optional
'developer_token'='<token>', // Developer Tokens are short lived
}
}
data_source = await client.dataSources.createDataSource({
body: ds
})
2. Client Credential Grant Authentication Mechanism
- Python Client
- TypeScript Client
from llama_cloud.types import CloudBoxDataSource
ds = {
'name': '<your-name>',
'source_type': 'BOX',
'component': CloudBoxDataSource(
folder_id='<folder_id>', # Optional
client_id='<client_id>',
client_secret='<client_secret>',
user_id='<user_id>', # Optional, if using enterprise_id
enterprise_id='<enterprise_id>' # Optional, if using user_id
)
}
data_source = client.data_sources.create_data_source(request=ds)
const ds = {
'name': '<your-name>',
'sourceType': 'BOX',
'component': {
'folder_id'='<folder_id>', // Optional
'client_id'='<client_id>',
'client_secret'='<client_secret>',
'user_id'='<user_id>', // Optional, if using enterprise_id
'enterprise_id'='<enterprise_id>' // Optional, if using user_id
}
}
data_source = await client.dataSources.createDataSource({
body: ds
})