Credentials

Credentials for user with Database and Data Storage Connectivity can be stored by the system.

To interact with Credentials API, you should use the Credential class.

List credentials

In order to retrieve the list of all credentials accessible for current user you can use Credential.list.

import datarobot as dr

credentials = dr.Credential.list()

Each Credential object contains the credential_id string field which can be used e.g. in Batch Predictions.

Basic credentials

You can store generic user/password credentials:

>>> import datarobot as dr
>>> cred = dr.Credential.create_basic(
...     name='my_db_cred',
...     user='<user>',
...     password='<password>',
... )
>>> cred
Credential('5e429d6ecf8a5f36c5693e0f', 'my_db_cred', 'basic'),

# store cred.credential_id

>>> cred = dr.Credential.get(credential_id)
>>> cred.credential_id
'5e429d6ecf8a5f36c5693e0f'

Stored credential can be used e.g. in Batch Bredictions for JDBC intake or output.

S3 credentials

You can store AWS credentials using the three parameters:

  • aws_access_key_id
  • aws_secret_access_key
  • aws_session_token
>>> import datarobot as dr
>>> cred = dr.Credential.create_s3(
...     name='my_s3_cred',
...     aws_access_key_id='<aws access key id>',
...     aws_secret_access_key='<aws secret access key>',
...     aws_session_token='<aws session token>',
... )
>>> cred
Credential('5e429d6ecf8a5f36c5693e03', 'my_s3_cred', 's3'),

# store cred.credential_id

>>> cred = dr.Credential.get(credential_id)
>>> cred.credential_id
'5e429d6ecf8a5f36c5693e03'

Stored credential can be used e.g. in Batch Bredictions for S3 intake or output.

OAUTH credentials

You can store oauth credentials in the store:

>>> import datarobot as dr
>>> cred = dr.Credential.create_oauth(
...     name='my_oauth_cred',
...     token='<token>',
...     refresh_token='<refresh_token>',
... )
>>> cred
Credential('5e429d6ecf8a5f36c5693e0f', 'my_oauth_cred', 'oauth'),

# store cred.credential_id

>>> cred = dr.Credential.get(credential_id)
>>> cred.credential_id
'5e429d6ecf8a5f36c5693e0f'

Credential Data

For methods that accept credential data instead of user/password, or credential ID:

{
    "credentialType": "basic",
    "user": "user123",
    "password": "pass123",
}
{
    "credentialType": "s3",
    "awsAccessKeyId": "key123",
    "awsSecretAccessKey": "secret123",
}
{
    "credentialType": "oauth",
    "oauthRefreshToken": "token123",
    "oauthClientId": "client123",
    "oauthClientSecret": "secret123",
}