Elastic Dropbox connector reference

edit

The Elastic Dropbox connector is a connector for Dropbox. This connector is written in Python using the Elastic connector framework.

View the source code for this connector (branch 8.16, compatible with Elastic 8.16).

Elastic managed connector reference

edit
View Elastic managed connector reference
Availability and prerequisites
edit

This connector is available as a managed connector in Elastic versions 8.10.0 and later.

To use this connector natively in Elastic Cloud, satisfy all managed connector requirements.

Create a Dropbox connector
edit

Use the UI

edit

To create a new Dropbox connector:

  1. In the Kibana UI, navigate to the Search → Content → Connectors page from the main menu, or use the global search field.
  2. Follow the instructions to create a new native Dropbox connector.

For additional operations, see Connectors UI in Kibana.

Use the API

edit

You can use the Elasticsearch Create connector API to create a new native Dropbox connector.

For example:

resp = client.connector.put(
    connector_id="my-{service-name-stub}-connector",
    index_name="my-elasticsearch-index",
    name="Content synced from {service-name}",
    service_type="{service-name-stub}",
    is_native=True,
)
print(resp)
const response = await client.connector.put({
  connector_id: "my-{service-name-stub}-connector",
  index_name: "my-elasticsearch-index",
  name: "Content synced from {service-name}",
  service_type: "{service-name-stub}",
  is_native: true,
});
console.log(response);
PUT _connector/my-dropbox-connector
{
  "index_name": "my-elasticsearch-index",
  "name": "Content synced from Dropbox",
  "service_type": "dropbox",
  "is_native": true
}
You’ll also need to create an API key for the connector to use.

The user needs the cluster privileges manage_api_key, manage_connector and write_connector_secrets to generate API keys programmatically.

To create an API key for the connector:

  1. Run the following command, replacing values where indicated. Note the id and encoded return values from the response:

    resp = client.security.create_api_key(
        name="my-connector-api-key",
        role_descriptors={
            "my-connector-connector-role": {
                "cluster": [
                    "monitor",
                    "manage_connector"
                ],
                "indices": [
                    {
                        "names": [
                            "my-index_name",
                            ".search-acl-filter-my-index_name",
                            ".elastic-connectors*"
                        ],
                        "privileges": [
                            "all"
                        ],
                        "allow_restricted_indices": False
                    }
                ]
            }
        },
    )
    print(resp)
    const response = await client.security.createApiKey({
      name: "my-connector-api-key",
      role_descriptors: {
        "my-connector-connector-role": {
          cluster: ["monitor", "manage_connector"],
          indices: [
            {
              names: [
                "my-index_name",
                ".search-acl-filter-my-index_name",
                ".elastic-connectors*",
              ],
              privileges: ["all"],
              allow_restricted_indices: false,
            },
          ],
        },
      },
    });
    console.log(response);
    POST /_security/api_key
    {
      "name": "my-connector-api-key",
      "role_descriptors": {
        "my-connector-connector-role": {
          "cluster": [
            "monitor",
            "manage_connector"
          ],
          "indices": [
            {
              "names": [
                "my-index_name",
                ".search-acl-filter-my-index_name",
                ".elastic-connectors*"
              ],
              "privileges": [
                "all"
              ],
              "allow_restricted_indices": false
            }
          ]
        }
      }
    }
  2. Use the encoded value to store a connector secret, and note the id return value from this response:

    resp = client.connector.secret_post(
        body={
            "value": "encoded_api_key"
        },
    )
    print(resp)
    const response = await client.connector.secretPost({
      body: {
        value: "encoded_api_key",
      },
    });
    console.log(response);
    POST _connector/_secret
    {
      "value": "encoded_api_key"
    }
  3. Use the API key id and the connector secret id to update the connector:

    resp = client.connector.update_api_key_id(
        connector_id="my_connector_id>",
        api_key_id="API key_id",
        api_key_secret_id="secret_id",
    )
    print(resp)
    const response = await client.connector.updateApiKeyId({
      connector_id: "my_connector_id>",
      api_key_id: "API key_id",
      api_key_secret_id: "secret_id",
    });
    console.log(response);
    PUT /_connector/my_connector_id>/_api_key_id
    {
      "api_key_id": "API key_id",
      "api_key_secret_id": "secret_id"
    }

Refer to the Elasticsearch API documentation for details of all available Connector APIs.

Usage
edit

To use this connector as a managed connector, see Elastic managed connectors.

For additional operations, see Connectors UI in Kibana.

Before you can configure your connector, you’ll need to:

Dropbox API Authorization
edit
Create Dropbox OAuth App
edit

You’ll need to create an OAuth app in the Dropbox platform by following these steps:

  1. Register a new app in the Dropbox App Console. Select Full Dropbox API app and choose the following required permissions:

    • files.content.read
    • sharing.read

      To use document level security, you’ll also need the following permissions:

    • team_info.read
    • team_data.member
    • team_data.content.read
    • members.read
  2. Once the app is created, make note of the app key and app secret values which you’ll need to configure the Dropbox connector on your Elastic deployment.
Generate a refresh Token
edit

To generate a refresh token, follow these steps:

  1. Go to the following URL, replacing <APP_KEY> with the app key value saved earlier: https://www.dropbox.com/oauth2/authorize?client_id=<APP_KEY>&response_type=code&token_access_type=offline

    The HTTP response should contain an authorization code that you’ll use to generate a refresh token. An authorization code can only be used once to create a refresh token.

  2. In your terminal, run the following cURL command, replacing <AUTHORIZATION_CODE>, <APP_KEY>:<APP_SECRET> with the values you saved earlier:

    curl -X POST "https://api.dropboxapi.com/oauth2/token?code=<AUTHORIZATION_CODE>&grant_type=authorization_code" -u "<APP_KEY>:<APP_SECRET>"

    Store the refresh token from the response to be used in the connector configuration.

    Make sure the response has a list of the following scopes:

    • account_info.read
    • files.content.read
    • files.metadata.read
    • sharing.read
    • team_info.read (if using document level security)
    • team_data.member (if using document level security)
    • team_data.content.read (if using document level security)
    • members.read (if using document level security)
Configuration
edit

The following configuration fields are required to set up the connector:

Path to fetch files/folders

The folder path to fetch files/folders from Dropbox. Default value is /.

This field can be bypassed by advanced sync rules.

App key
The App Key to authenticate your Dropbox application.
App secret
The App Secret to authenticate your Dropbox application.
Refresh token
The refresh token to authenticate your Dropbox application.
Enable document level security
Toggle to enable document level security (DLS). When enabled, full syncs will fetch access control lists for each document and store them in the _allow_access_control field. Access control syncs will fetch users' access control lists and store them in a separate index.
Include groups and inherited users
Appears when document level security is enabled. Include groups and inherited users when indexing permissions.

Enabling Include groups and inherited users will cause a signficant performance degradation.

Documents and syncs
edit

The connector syncs the following objects and entities:

  • Files

    • Includes metadata such as file name, path, size, content, etc.
  • Folders

Due to a Dropbox issue, metadata updates to Paper files from Dropbox Paper are not immediately reflected in the Dropbox UI. This delays the availability of updated results for the connector. Once the metadata changes are visible in the Dropbox UI, the updates are available.

  • Content from files bigger than 10 MB won’t be extracted. (Self-managed connectors can use the self-managed local extraction service to handle larger binary files.)
  • Currently, the connector doesn’t retrieve files from shared Team folders.
  • Permissions are not synced by default. If document level security (DLS) is not enabled all documents indexed to an Elastic deployment will be visible to all users with access to that Elastic Deployment.
Sync types
edit

Full syncs are supported by default for all connectors.

This connector also supports incremental syncs.

Sync rules
edit

Basic sync rules are identical for all connectors and are available by default.

Advanced sync rules
edit

A full sync is required for advanced sync rules to take effect.

The following section describes advanced sync rules for this connector.

Advanced sync rules for Dropbox allow you to sync Dropbox files based on a query that matches strings in the filename. You can optionally filter the results of the query by file_extensions or file_categories. When both are provided, priority is given to file_categories. We have some examples below for illustration.

======= Example: Query only

[
  {
    "query": "confidential"
  },
  {
    "query": "dropbox"
  }
]

======= Example: Query with file extension filter

[
  {
    "query": "dropbox",
    "options": {
      "file_extensions": [
        "txt",
        "pdf"
      ]
    }
  }
]

======= Example: Query with file category filter

[
  {
    "query": "test",
    "options": {
      "file_categories": [
        {
          ".tag": "paper"
        },
        {
          ".tag": "png"
        }
      ]
    }
  }
]

======= Limitations

  • Content extraction is not supported for Dropbox Paper files when advanced sync rules are enabled.
Known issues
edit

Refer to Known issues for a list of known issues for all connectors.

Troubleshooting
edit

See Troubleshooting for a list of troubleshooting tips for all connectors.

Security
edit

See Security for a list of security tips for all connectors.

Content extraction
edit

See Content extraction.

Self-managed connector

edit
View self-managed connector reference
Availability and prerequisites
edit

This connector is available as a self-managed self-managed connector.

This self-managed connector is compatible with Elastic versions 8.9.0+.

To use this connector, satisfy all self-managed connector requirements.

Create a Dropbox connector
edit

Use the UI

edit

To create a new Dropbox connector:

  1. In the Kibana UI, navigate to the Search → Content → Connectors page from the main menu, or use the global search field.
  2. Follow the instructions to create a new Dropbox self-managed connector.

Use the API

edit

You can use the Elasticsearch Create connector API to create a new self-managed Dropbox self-managed connector.

For example:

resp = client.connector.put(
    connector_id="my-{service-name-stub}-connector",
    index_name="my-elasticsearch-index",
    name="Content synced from {service-name}",
    service_type="{service-name-stub}",
)
print(resp)
const response = await client.connector.put({
  connector_id: "my-{service-name-stub}-connector",
  index_name: "my-elasticsearch-index",
  name: "Content synced from {service-name}",
  service_type: "{service-name-stub}",
});
console.log(response);
PUT _connector/my-dropbox-connector
{
  "index_name": "my-elasticsearch-index",
  "name": "Content synced from Dropbox",
  "service_type": "dropbox"
}
You’ll also need to create an API key for the connector to use.

The user needs the cluster privileges manage_api_key, manage_connector and write_connector_secrets to generate API keys programmatically.

To create an API key for the connector:

  1. Run the following command, replacing values where indicated. Note the encoded return values from the response:

    resp = client.security.create_api_key(
        name="connector_name-connector-api-key",
        role_descriptors={
            "connector_name-connector-role": {
                "cluster": [
                    "monitor",
                    "manage_connector"
                ],
                "indices": [
                    {
                        "names": [
                            "index_name",
                            ".search-acl-filter-index_name",
                            ".elastic-connectors*"
                        ],
                        "privileges": [
                            "all"
                        ],
                        "allow_restricted_indices": False
                    }
                ]
            }
        },
    )
    print(resp)
    const response = await client.security.createApiKey({
      name: "connector_name-connector-api-key",
      role_descriptors: {
        "connector_name-connector-role": {
          cluster: ["monitor", "manage_connector"],
          indices: [
            {
              names: [
                "index_name",
                ".search-acl-filter-index_name",
                ".elastic-connectors*",
              ],
              privileges: ["all"],
              allow_restricted_indices: false,
            },
          ],
        },
      },
    });
    console.log(response);
    POST /_security/api_key
    {
      "name": "connector_name-connector-api-key",
      "role_descriptors": {
        "connector_name-connector-role": {
          "cluster": [
            "monitor",
            "manage_connector"
          ],
          "indices": [
            {
              "names": [
                "index_name",
                ".search-acl-filter-index_name",
                ".elastic-connectors*"
              ],
              "privileges": [
                "all"
              ],
              "allow_restricted_indices": false
            }
          ]
        }
      }
    }
  2. Update your config.yml file with the API key encoded value.

Refer to the Elasticsearch API documentation for details of all available Connector APIs.

Usage
edit

Before you can configure your connector, you’ll need to:

To use this connector as a self-managed connector, see Self-managed connectors Once set up, for additional usage operations, see Connectors UI in Kibana.

Dropbox API Authorization
edit
Create Dropbox OAuth App
edit

You’ll need to create an OAuth app in the Dropbox platform by following these steps:

  1. Register a new app in the Dropbox App Console. Select Full Dropbox API app and choose the following required permissions:

    • files.content.read
    • sharing.read

      To use document level security, you’ll also need the following permissions:

    • team_info.read
    • team_data.member
    • team_data.content.read
    • members.read
  2. Once the app is created, make note of the app key and app secret values which you’ll need to configure the Dropbox connector on your Elastic deployment.
Generate a refresh Token
edit

To generate a refresh token, follow these steps:

  1. Go to the following URL, replacing <APP_KEY> with the app key value saved earlier: https://www.dropbox.com/oauth2/authorize?client_id=<APP_KEY>&response_type=code&token_access_type=offline

    The HTTP response should contain an authorization code that you’ll use to generate a refresh token. An authorization code can only be used once to create a refresh token.

  2. In your terminal, run the following cURL command, replacing <AUTHORIZATION_CODE>, <APP_KEY>:<APP_SECRET> with the values you saved earlier:

    curl -X POST "https://api.dropboxapi.com/oauth2/token?code=<AUTHORIZATION_CODE>&grant_type=authorization_code" -u "<APP_KEY>:<APP_SECRET>"

    Store the refresh token from the response to be used in the connector configuration.

    Make sure the response has a list of the following scopes:

    • account_info.read
    • files.content.read
    • files.metadata.read
    • sharing.read
    • team_info.read (if using document level security)
    • team_data.member (if using document level security)
    • team_data.content.read (if using document level security)
    • members.read (if using document level security)
Configuration
edit

When using the self-managed connector workflow, initially these fields will use the default configuration set in the connector source code. These are set in the get_default_configuration function definition.

These configurable fields will be rendered with their respective labels in the Kibana UI. Once connected, you’ll be able to update these values in Kibana.

The following configuration fields are required to set up the connector:

path
The folder path to fetch files/folders from Dropbox. Default value is /.
app_key (required)
The App Key to authenticate your Dropbox application.
app_secret (required)
The App Secret to authenticate your Dropbox application.
refresh_token (required)
The refresh token to authenticate your Dropbox application.
use_document_level_security
Toggle to enable document level security (DLS). When enabled, full syncs will fetch access control lists for each document and store them in the _allow_access_control field. Access control syncs will fetch users' access control lists and store them in a separate index.
retry_count
The number of retry attempts after a failed request to Dropbox. Default value is 3.
concurrent_downloads
The number of concurrent downloads for fetching attachment content. This can help speed up content extraction of attachments. Defaults to 100.
use_text_extraction_service
Requires a separate deployment of the Elastic Text Extraction Service. Requires that pipeline settings disable text extraction. Default value is False.
use_document_level_security
Toggle to enable document level security (DLS). When enabled, full syncs will fetch access control lists for each document and store them in the _allow_access_control field. Access control syncs will fetch users' access control lists and store them in a separate index.
include_inherited_users_and_groups
Depends on document level security being enabled. Include groups and inherited users when indexing permissions.

Enabling Include groups and inherited users will cause a signficant performance degradation.

Deployment using Docker
edit

You can deploy the Dropbox connector as a self-managed connector using Docker. Follow these instructions.

Step 1: Download sample configuration file

Download the sample configuration file. You can either download it manually or run the following command:

curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml

Remember to update the --output argument value if your directory name is different, or you want to use a different config file name.

Step 2: Update the configuration file for your self-managed connector

Update the configuration file with the following settings to match your environment:

  • elasticsearch.host
  • elasticsearch.api_key
  • connectors

If you’re running the connector service against a Dockerized version of Elasticsearch and Kibana, your config file will look like this:

# When connecting to your cloud deployment you should edit the host value
elasticsearch.host: http://host.docker.internal:9200
elasticsearch.api_key: <ELASTICSEARCH_API_KEY>

connectors:
  -
    connector_id: <CONNECTOR_ID_FROM_KIBANA>
    service_type: dropbox
    api_key: <CONNECTOR_API_KEY_FROM_KIBANA> # Optional. If not provided, the connector will use the elasticsearch.api_key instead

Using the elasticsearch.api_key is the recommended authentication method. However, you can also use elasticsearch.username and elasticsearch.password to authenticate with your Elasticsearch instance.

Note: You can change other default configurations by simply uncommenting specific settings in the configuration file and modifying their values.

Step 3: Run the Docker image

Run the Docker image with the Connector Service using the following command:

docker run \
-v ~/connectors-config:/config \
--network "elastic" \
--tty \
--rm \
docker.elastic.co/integrations/elastic-connectors:8.16.1.0 \
/app/bin/elastic-ingest \
-c /config/config.yml

Refer to DOCKER.md in the elastic/connectors repo for more details.

Find all available Docker images in the official registry.

We also have a quickstart self-managed option using Docker Compose, so you can spin up all required services at once: Elasticsearch, Kibana, and the connectors service. Refer to this README in the elastic/connectors repo for more information.

Documents and syncs
edit

The connector syncs the following objects and entities:

  • Files

    • Includes metadata such as file name, path, size, content, etc.
  • Folders

Due to a Dropbox issue, metadata updates to Paper files from Dropbox Paper are not immediately reflected in the Dropbox UI. This delays the availability of updated results for the connector. Once the metadata changes are visible in the Dropbox UI, the updates are available.

  • Content from files bigger than 10 MB won’t be extracted by default. You can use the self-managed local extraction service to handle larger binary files.
  • Currently, the connector doesn’t retrieve files from shared Team folders.
  • Permissions are not synced by default. If document level security (DLS) is not enabled all documents indexed to an Elastic deployment will be visible to all users with access to that Elastic Deployment.
Sync types
edit

Full syncs are supported by default for all connectors.

This connector also supports incremental syncs.

Sync rules
edit

Basic sync rules are identical for all connectors and are available by default.

Advanced sync rules
edit

A full sync is required for advanced sync rules to take effect.

The following section describes advanced sync rules for this connector.

Advanced sync rules for Dropbox allow you to sync Dropbox files based on a query that matches strings in the filename. You can optionally filter the results of the query by file_extensions or file_categories. When both are provided, priority is given to file_categories. We have some examples below for illustration.

======= Example: Query only

[
  {
    "query": "confidential"
  },
  {
    "query": "dropbox"
  }
]

======= Example: Query with file extension filter

[
  {
    "query": "dropbox",
    "options": {
      "file_extensions": [
        "txt",
        "pdf"
      ]
    }
  }
]

======= Example: Query with file category filter

[
  {
    "query": "test",
    "options": {
      "file_categories": [
        {
          ".tag": "paper"
        },
        {
          ".tag": "png"
        }
      ]
    }
  }
]

======= Limitations

  • Content extraction is not supported for Dropbox Paper files when advanced sync rules are enabled.
End-to-end Testing
edit

The connector framework enables operators to run functional tests against a real data source. Refer to Connector testing for more details.

To perform E2E testing for the Dropbox connector, run the following command:

$ make ftest NAME=dropbox

For faster tests, add the DATA_SIZE=small flag:

make ftest NAME=dropbox DATA_SIZE=small
Known issues
edit

Refer to Known issues for a list of known issues for all connectors.

Troubleshooting
edit

See Troubleshooting for a list of troubleshooting tips for all connectors.

Security
edit

See Security for a list of security tips for all connectors.

Content extraction
edit

See Content extraction.