Data connectors
The DataConnectorsClient class provides methods to connect an external data provider, such as Google Drive, and manage the resulting connections.
Import limits:
- Video: Up to 10 GB
- Audio: Up to 4 GB
- Images: Up to 32 MB
You can import up to 100 files per request.
Workflow
Start the OAuth flow with the data_connectors.authorize_connection method, passing your redirect URL. Redirect the user to the authorization URL you receive. After the user grants access in the browser, the platform redirects them back, with the identifier of the new connection in the connection_id query parameter. Store this identifier.
Generate a short-lived access token with the data_connectors.create_connection_picker_token method. Use it with the Google Drive Picker so the user can select files, and store the identifier of each selected file.
Import the selected files with the imports.import_files method. Each accepted file becomes an asset in the processing status.
Poll the imports.retrieve_import method until each item reaches the ready or failed status. Once an item is ready, use its asset identifier with the rest of the SDK.
(Optional) Disconnect the account with the data_connectors.delete_connection method. The platform revokes access and deletes the stored tokens. Assets you already imported are retained.
Methods
Authorize a connection
Description: This method starts the OAuth authorization flow for a data connector. The platform returns an authorization URL. Redirect the user to this URL so they can grant access to their account.
After the user grants or denies access, the platform redirects them to the redirect URL you provided, with the outcome appended to that URL as query parameters. Read these parameters from the redirect that your application receives:
connection_id: The identifier of the new connection, returned on success. Store this value and pass it as theconnection_idargument in later requests.status: Set tookon success.custom_id: The label you supplied, returned on success when you provided one.error: An error code, returned instead of the other parameters when the user denies access or the flow fails.
Function signature and example:
Parameters
Return value
Returns an AuthorizeConnectionResponse object. The AuthorizeConnectionResponse class contains the following properties:
API Reference
List connections
Description: This method returns a list of the connections in your account. The platform returns your connections sorted by creation date, with the newest at the top of the list.
Function signature and example:
Parameters
Return value
Returns a ListConnectionsResponse object. The ListConnectionsResponse class contains the following properties:
API Reference
Retrieve a connection
Description: This method retrieves details about the specified connection.
Function signature and example:
Parameters
Return value
Returns a Connection object. The Connection class contains the following properties:
The ConnectionAccount class contains the following properties:
API Reference
Delete a connection
Description: This method disconnects the specified connection. The platform revokes access at the provider and deletes the stored tokens. Assets imported through this connection are retained.
Function signature and example:
Parameters
Return value
This method does not return a value.
API Reference
Generate a picker token
Description: This method generates a short-lived, read-only access token that you use with the provider’s file picker, such as the Google Drive Picker. The platform never returns the refresh token of the connection.
Function signature and example:
Parameters
Return value
Returns a CreateConnectionPickerTokenResponse object. The CreateConnectionPickerTokenResponse class contains the following properties: