This page was recently updated. What do you think about it? Let us know!.
- A Google Cloud account.
- The Google Drive API enabled in the account. Learn how.
-
Within the account, a Google Cloud service account and its related
credentials.json
key file or its contents in JSON format. Create a service account. Create credentials for a service account. To ensure maximum compatibility across Unstructured service offerings, you should give the service account key information to Unstructured as a single-line string that contains the contents of the downloaded service account key file (and not the service account key file itself). To print this single-line string without line breaks, suitable for copying, you can run one of the following commands from your Terminal or Command Prompt. In this command, replace<path-to-downloaded-key-file>
with the path to thecredentials.json
key file that you downloaded by following the preceding instructions.-
For macOS or Linux:
-
For Windows:
-
For macOS or Linux:
- A Google Drive shared folder or shared drive.
- Give the service account access to the shared folder or shared drive. To do this, share the folder or drive with the service account’s email address. Learn how. Learn more.
-
Get the shared folder’s ID or shared drive’s ID. This is a part of the URL for your Google Drive shared folder or shared drive, represented in the following URL as
{folder_id}
:https://drive.google.com/drive/folders/{folder-id}
.
Document permissions metadata
The source connector outputs any permissions information that it can find in the source location about the processed source documents and associates that information with each corresponding element that is generated. This permissions information is output into thepermissions_data
field, which is within the
data_source
field under the element’s metadata
field. This information lists the users or groups, if any, that have
permissions to read, update, or delete the element’s associated source document.
The following example shows what the output looks like. Ellipses indicate content that has been omitted from this example for brevity.
CLI, Python
-
GOOGLE_DRIVE_FOLDER_ID
- The folder or drive ID, represented by--drive-id
(CLI) ordrive_id
(Python). -
One of the following:
GCP_SERVICE_ACCOUNT_KEY_FILEPATH
- The path to thecredentials.json
key file, represented by--service-account-key-path
(CLI) orservice_account_key_path
(Python).GCP_SERVICE_ACCOUNT_KEY_STRING
- The contents of thecredentials.json
key file as a string, represented by--service-account-key
(CLI) orservice_account_key
(Python).
To use
--extensions
with a comma-separated list (CLI) or extensions
with an array of strings (Python) to process files with only those extensions,
do not include the leading dot in the file extensions. For example, use pdf
or docx
instead of .pdf
or .docx
.--partition-by-api
option (CLI) or partition_by_api
(Python) parameter to specify where files are processed:
-
To do local file processing, omit
--partition-by-api
(CLI) orpartition_by_api
(Python), or explicitly specifypartition_by_api=False
(Python). Local file processing does not use an Unstructured API key or API URL, so you can also omit the following, if they appear:--api-key $UNSTRUCTURED_API_KEY
(CLI) orapi_key=os.getenv("UNSTRUCTURED_API_KEY")
(Python)--partition-endpoint $UNSTRUCTURED_API_URL
(CLI) orpartition_endpoint=os.getenv("UNSTRUCTURED_API_URL")
(Python)- The environment variables
UNSTRUCTURED_API_KEY
andUNSTRUCTURED_API_URL
-
To send files to the Unstructured Partition Endpoint for processing, specify
--partition-by-api
(CLI) orpartition_by_api=True
(Python). Unstructured also requires an Unstructured API key and API URL, by adding the following:--api-key $UNSTRUCTURED_API_KEY
(CLI) orapi_key=os.getenv("UNSTRUCTURED_API_KEY")
(Python)--partition-endpoint $UNSTRUCTURED_API_URL
(CLI) orpartition_endpoint=os.getenv("UNSTRUCTURED_API_URL")
(Python)- The environment variables
UNSTRUCTURED_API_KEY
andUNSTRUCTURED_API_URL
, representing your API key and API URL, respectively.
You must specify the API URL only if you are not using the default API URL for Unstructured Ingest, which applies to Starter and Team accounts.The default API URL for Unstructured Ingest ishttps://api.unstructuredapp.io/general/v0/general
, which is the API URL for the Unstructured Partition Endpoint. However, you should always use the URL that was provided to you when your Unstructured account was created. If you do not have this URL, email Unstructured Support at support@unstructured.io.If you do not have an API key, get one now.If you are using an Enterprise account, the process for generating Unstructured API keys, and the Unstructured API URL that you use, are different. For instructions, see your Unstructured account administrator, or email Unstructured Support at support@unstructured.io.
Output a key file’s contents as a string
If you need to convert the contents of acredentials.json
file into a string, you could use a Python script such as the following.
This script takes the local path to the key file as input and outputs the key file’s contents as a string.
Python