UID2 SDK for Python
Project description
UID2 SDK for Python
The UID 2 Project is subject to Tech Lab IPR’s Policy and is managed by the IAB Tech Lab Addressability Working Group and Privacy & Rearc Commit Group. Please review the governance rules.
This SDK simplifies integration with UID2 for those using Python.
Dependencies
This SDK supports Python 3.6 and above.
Quick Start
Connect to the UID2 service, refresh the encryption keys, and then use the keys to decrypt an advertising token, to arrive at the corresponding advertising ID:
from uid2_client import Uid2Client, decrypt_token
client = Uid2Client('https://prod.uidapi.com', 'my-auth-token', 'my-secret-key')
keys = client.refresh_keys()
advertising_token = 'AgAAAANRdREk+IWqqnQkZ2rZdK0TgSUP/owLryysSkUGZJT+Gy551L1WJMAZA/G2B1UMDQ20WAqwwTu6o9TexWyux0lg0HHIbmJjN6IYwo+42KC8ugaR+PX0y18qQ+3yzkxmJ/ee//4IGu/1Yq4AmO4ArXN6CeszPTxByTkysVqyQVNY2A=='
decrypted_token = decrypt_token(advertising_token, keys)
print(decrypted_token.uid2)
Additional examples are in the [examples] directory:
Development
First, build the Docker image with Python 3.6 and all dev dependencies. This is required for all subsequent commands. Run the following:
make docker
Run unit tests:
make test
Build a bdist wheel:
make wheel
Get access to an interactive shell within the Python 3.6 Docker image:
make shell
Example Usage
To run all the example applications:
make examples BASE_URL=https://prod.uidapi.com AUTH_KEY=my-auth-key SECRET_KEY=my-secret-key \
AD_TOKEN=AgAAAANRdREk+IWqqnQkZ2rZdK0TgSUP/owLryysSkUGZJT+Gy551L1WJMAZA/G2B1UMDQ20WAqwwTu6o9TexWyux0lg0HHIbmJjN6IYwo+42KC8ugaR+PX0y18qQ+3yzkxmJ/ee//4IGu/1Yq4AmO4ArXN6CeszPTxByTkysVqyQVNY2A==
Alternatively, you can run specific examples:
make example_client BASE_URL=https://prod.uidapi.com AUTH_KEY=my-auth-key SECRET_KEY=my-secret-key \
AD_TOKEN=AgAAAANRdREk+IWqqnQkZ2rZdK0TgSUP/owLryysSkUGZJT+Gy551L1WJMAZA/G2B1UMDQ20WAqwwTu6o9TexWyux0lg0HHIbmJjN6IYwo+42KC8ugaR+PX0y18qQ+3yzkxmJ/ee//4IGu/1Yq4AmO4ArXN6CeszPTxByTkysVqyQVNY2A==
make example_auto_refresh BASE_URL=https://prod.uidapi.com AUTH_KEY=my-auth-key SECRET_KEY=my-secret-key \
AD_TOKEN=AgAAAANRdREk+IWqqnQkZ2rZdK0TgSUP/owLryysSkUGZJT+Gy551L1WJMAZA/G2B1UMDQ20WAqwwTu6o9TexWyux0lg0HHIbmJjN6IYwo+42KC8ugaR+PX0y18qQ+3yzkxmJ/ee//4IGu/1Yq4AmO4ArXN6CeszPTxByTkysVqyQVNY2A==
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for uid2_client-2.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc238539481560b5c64ab154b41d9941f7f10aeeba5c1908f7886c66217e9dea |
|
MD5 | 347669b6767a8e60947ca5aeebca9bc6 |
|
BLAKE2b-256 | a5f1a0fd16315bfdd2e5331ee693464c89fbf72985b33b99e1e577c667d24cc8 |