Authentication
Section Contents
Authentication#
The StreamSets Platform SDK for Python uses API Credentials for authentication.
The Platform SDK also supports management of API credentials for Control Hub, including creation of credentials for themselves or, for other users, deletion of credentials, activating or deactivating existing credentials and, renaming credentials.
For more details, refer to the StreamSets Platform Documentation.
Note
Currently, you need to create a set of API credentials via the Platform UI before being able to use the Platform SDK. The actions below are possible only after having at least 1 set of API credentials.
Creating API Credentials#
To create API credentials in the Platform UI, you go to Manage > API Credentials and click on the +
icon.

To accomplish the same task using the Platform SDK, you need to instantiate a streamsets.sdk.sch_models.ApiCredentialBuilder
instance and, create a new streamsets.sdk.sch_models.ApiCredential
object.
To instantiate the builder instance use streamsets.sdk.ControlHub.get_api_credential_builder()
method.
You can then call the streamsets.sdk.sch_models.ApiCredentialBuilder.build()
method to create the new API credentials and give them a name by supplying a value for the name
parameter.
After creating the new API credentials, pass the resulting streamsets.sdk.sch_models.ApiCredential
to the streamsets.sdk.ControlHub.add_api_credential()
method to register the credentials in Platform.
# Instantiate the ApiCredentialBuilder
credential_builder = sch.get_api_credential_builder()
# Give a name to the credentials
new_credentials = credential_builder.build(name='name for new credentials')
# Add them to Platform
sch.add_api_credentials(new_credentials)
Note
The attributes credential_id
and auth_token
are only populated once the credentials are registered on Platform.
Warning
The credential_id
and auth_token
values for a set of API credentials are private key values and should be safeguarded as sensitive passwords.
These values are not retrievable after the API credentials have been created.
If the resulting API credentials are deleted from local memory and the values are not stored, they will be lost.
Connecting to Control Hub#
Connect to Control Hub by creating an instance of streamsets.sdk.ControlHub
, passing in
the API Credentials.
# Connect to the StreamSets Platform.
sch = ControlHub(credential_id=<credential ID>, token=<token>)
You can find more information for API Credentials on it’s documentation page.