Python

This guide takes you through using the Vizzly Python Client (opens in a new tab) to sign the identity config securely on your servers.

Install

pip3 install git+https://github.com/vizzly-co/python.git#egg=vizzly
Using poetry?

For Python Poetry (opens in a new tab) projects, add the following content to your pyproject.toml file, under the [tool.poetry.dependencies] section

vizzly = { git = "https://github.com/vizzly-co/python.git", branch = "main" }

then run poetry install.

Import

import vizzly

Create the dashboard access token

# Access token to permit dashboard configuration management
dashboard_access_token = vizzly.sign_dashboard_access_token(
  expiry_ttl_in_minutes=60,
  # https://docs.vizzly.co/identity/properties/project-id
  project_id='prj_123',
  # https://docs.vizzly.co/identity/properties/user-reference
  user_reference='usr-123',
  private_key=private_key
)

Create the data access token

data_access_token = vizzly.sign_data_access_token(
  expiry_ttl_in_minutes=20,
  # https://docs.vizzly.co/identity/properties/data-sets
  data_set_ids='*',
  # https://docs.vizzly.co/identity/properties/secure-filters
  secure_filters={},
  # Contents of your Vizzly private key
  private_key=private_key
)

Create the query engine access token (optional)

OptionalSelf-hostedAdvanced
query_engine_access_token = vizzly.sign_query_engine_access_token(
  expiry_ttl_in_minutes=60,
  # https://docs.vizzly.co/identity/properties/database-schema-access
  allow_data_preview_access=True,
  allow_database_schema_access=True,
  private_key=private_key
)

Next steps

Now that you have created the access tokens, you will want to return the access tokens to the client. For example, you might be calling this auth endpoint from the identity function used on the Dashboard. If that's the case, then you'll want to return the tokens in a JSON structure of this format;

{
  /** Required */
  dashboardAccessToken: string;
  /** Required if you are using the self-hosted Vizzly query engine */
  dataAccessToken?: string;
  /** Optional if the user has access to the config manager */
  queryEngineAccessToken?: string;
}

Now that you are finished generating access tokens for Vizzly, you might be interested in;