Skip to main content

Python SDK

Read this guide to learn how to use the Python SDK. The Python SDK has some pre-built code examples you can use to learn how to build tools that can interact with Identity Security Cloud.

Requirements

You need the following to use the Python SDK:

  • Python version 3.7 or above. You can download it here. You can use python --version to check your version.

  • Your tenant name in Identity Security Cloud. To learn how to find it, refer to Getting Started. The SDK will use this tenant name to connect to your Identity Security Cloud instance.

  • A PAT with a client secret and ID. To learn how to create one in Identity Security Cloud, refer to Personal Access Tokens. The SDK will use this PAT to authenticate with the SailPoint APIs.

Setup

CLI Assisted (Recommended)

The SailPoint CLI offers a few commands that will allow you to quickly get started with the Python SDK. To learn how to install and use the SailPoint CLI, refer to SailPoint CLI.

Once the CLI is installed and configured, run this command to create a new Python project with the Python SDK:

sail sdk init python python-example

Running this command will create the structure for your project:

|-- python-example
| |-- requirements.txt
| |-- sdk.py

Navigate into your project folder and run this command to install the required dependencies:

pip install -r requirements.txt

The SDK is now installed. To learn how to configure the SDK, refer to the Configure section.

Manual Installation

To begin your Python project, you will need to create a directory for your project.

To create a project directory, run this command:

mkdir python-example

Then run this command to change into your project directory:

cd python-example

To initialize your project and install the SDK, create the "requirements.txt" file with the following line in your project directory:

sailpoint >= 1.0.0

To install the SDK and its dependencies, run this command:

pip install -r requirements.txt

The SDK is now installed. To learn how to configure the SDK, refer to the Configure section.

Configure

You must provide configuration to the SDK so it can authenticate to your SailPoint tenant and make API calls. To do so, you can either use a configuration file, "config.json", or environment variables.

Configuration File

The SDK requires a configuration file to be named "config.json". Within the file, provide these key/value pairs: ClientId, ClientSecret, BaseURL.

Details

CLI Assisted (Recommended) The SailPoint CLI offers a command to generate the "config.json" file with your currently configured CLI credentials.

sail sdk init config

If you have multiple environments configured with the CLI, you can pass an additional parameter to state the environment you wish to create a "config.json" for.

To pass an additional parameter that states the environment you want to configure, run this command:

sail sdk init config --env devrel

Example "config.json"

{
"ClientId": "g0567b766b413b22c05c66e75d532f1b",
"ClientSecret": "cabd0e950a7230b63c1ff45be33fb22065b382b6251a73c61177a8bb5482fcc7",
"BaseURL": "https://[tenant].api.identitynow.com"
}
Manual Configuration

Create a file named "config.json", and provide these key/value pairs: ClientID, ClientSecret, BaseUrl.

Example "config.json"

{
"ClientId": "g0567b766b413b22c05c66e75d532f1b",
"ClientSecret": "cabd0e950a7230b63c1ff45be33fb22065b382b6251a73c61177a8bb5482fcc7",
"BaseURL": "https://[tenant].api.identitynow.com"
}
warning

Please ensure this file is ignored in your version control system (ex. .gitignore for git)

Environment variable configuration

You can also store your configuration in environment variables.

To get your environment variables to persist across terminal sessions, add these exports to your shell profile, something like ~/.bash_profile.

export SAIL_BASE_URL=https://[tenant].api.identitynow.com
export SAIL_CLIENT_ID=[clientID]
export SAIL_CLIENT_SECRET=[clientSecret]

Discuss

You can use this SDK to build new tools that extend your Identity Security Cloud platform and improve experiences across your organization. Use this guide to get started, and if you have questions, don't hesitate to reach out on the SailPoint Developer Community forum at https://developer.sailpoint.com/discuss!

Getting Started

To get started using the SDK, refer to the Getting Started Guide.