Service Account

Authenticates the API using Service Account credentials. Details about the authentication flow implementation can be found in our OAuth2 Example.


  • To authenticate using this method, a Service Account with sufficient permissions is required. If you’re unfamiliar with this concept, read our Introduction to Service Accounts.


The following snippet authentications all functionality in the package at once.

import os
import disruptive as dt

# It is good practice to fetch credentials from an environment or file.
key_id = os.environ.get('DT_SERVICE_ACCOUNT_KEY_ID', '')
secret = os.environ.get('DT_SERVICE_ACCOUNT_SECRET', '')
email = os.environ.get('DT_SERVICE_ACCOUNT_EMAIL', '')

# Using the fetched credentials, authenticate the package.
dt.default_auth = dt.Auth.service_account(key_id, secret, email)


disruptive.Auth.service_account(key_id, secret, email)

This method uses an OAuth2 authentication flow. With the provided credentials, a JWT is created and exchanged for an access token.

  • key_id (str) – Unique Service Account key ID.

  • secret (str) – Service Account secret.

  • email (str) – Unique Service Account email address.


auth – Object to initialize and maintain authentication to the REST API.

Return type:



class disruptive.authentication.ServiceAccountAuth(key_id, secret, email)

Ensures that the access token is available and up-to-date.


token_endpoint (str) – URL to which the jwt is exchanged for an access token.