Step 1: Environmental Configuration

You can store environmental variables in a YAML file in your local environment.

Once you have your API credentials, you need a way to invoke them when calling the API. LiveRamp's recommendation is to do so by installing environment variables for static inputs and leveraging them to generate a new bearer token for authentication when accessing the API.

For this tutorial, the variables are:

HABU_ORGANIZATION={ORG_UUID}
HABU_API=https://api.habu.com
HABU_API_CLIENT={API_CLIENT}
HABU_API_SECRET={API_SECRET}

Where:

Parameter ValueDescription
ORG_UUIDRefers to your API user's Clean Room organization ID, which you can find in the URL of the Clean Room UI. Just navigate to the Clean Room section of LiveRamp Connect, and you will see it in the URL after organization= as shown in the following pattern: connect.liveramp.com/cleanroom/clean-rooms?customer_id={customer_ID}&organization={organization_ID}
HABU_APIUse thehttps://api.habu.combase URL
API_CLIENTRefers to the client ID provided when you (or your account admin) created the API user. Go to the Manage API Key page.
API_SECRETRefers to the API secret provided when you created the API user.

Authenticating in Python

This tutorial assumes that you have a local YAML file created (using the key-value formats for the variables defined above) and are running the notebook/cells from your local machine.

Depending on your company's policies and execution environment setup, you may wish to authenticate by referencing another service for storing and generating credentials.

The following classes are recommended for use in repeatably authenticating and executing calls via the API:

  • BaseApi: Class to reference login credentials, define environment variables for the session, define call types, and rotate your bearer token for authentication.
  • CleanRoom(BaseApi): Defines all of the operations you may wish to execute as part of your workflow.

These example classes are provided in step 2 for use with this tutorial.

Authenticating Locally

To authenticate locally, create a YAML file with your relevant environment variables, import the relevant packages as in the cell below, and run the example BaseAPI and CleanRoom classes provided in in step 2.

# Import relevant packages
import os
import yaml
import datetime
import time
import pytz
import requests
import base64
import json
import urllib.parse

import pandas as pd