|
2 | 2 |
|
3 | 3 | 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](https://github.com/IABTechLab/uid2-core/blob/master/Software%20Development%20and%20Release%20Procedures.md). |
4 | 4 |
|
5 | | -This SDK simplifies integration with UID2 for those using Python. |
| 5 | +This document includes: |
| 6 | +* [Who Is this SDK for?](#who-is-this-sdk-for) |
| 7 | +* [Requirements](#requirements) |
| 8 | +* [Install](#install) |
| 9 | +* [Usage for DSPs](#usage-for-dsps) |
| 10 | +* [Usage for UID2 Sharers](#usage-for-uid2-sharers) |
| 11 | +* [Development](#development) |
| 12 | + * [Example Usage](#example-usage) |
6 | 13 |
|
7 | | -## Dependencies |
| 14 | +## Who Is this SDK for? |
| 15 | + |
| 16 | +This SDK simplifies integration with UID2 for DSPs and UID Sharers, as described in [UID2 Integration Guides](https://unifiedid.com/docs/category/integration-guides). |
| 17 | + |
| 18 | +## Requirements |
8 | 19 |
|
9 | 20 | This SDK supports Python 3.6 and above. |
10 | 21 |
|
11 | | -## Quick Start |
| 22 | +## Install |
12 | 23 |
|
13 | | -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: |
| 24 | +The SDK can be installed using pip. |
| 25 | +``` |
| 26 | +pip install uid2-client |
| 27 | +``` |
14 | 28 |
|
| 29 | +## Usage for DSPs |
| 30 | + |
| 31 | +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: |
| 32 | +For examples of usage for DSPs, see [sample_client.py](examples/sample_client.py) and [sample_auto_refresh.py](examples/sample_auto_refresh.py) |
15 | 33 | ``` |
16 | | -from uid2_client import Uid2Client, decrypt |
| 34 | +from uid2_client import Uid2ClientFactory |
17 | 35 |
|
18 | | -client = Uid2Client('https://prod.uidapi.com', 'my-auth-token', 'my-secret-key') |
19 | | -keys = client.refresh_keys() |
| 36 | +# for UID2 (for EUID use EuidClientFactory) |
| 37 | +client = Uid2ClientFactory.create('https://prod.uidapi.com', 'my-auth-token', 'my-secret-key') |
| 38 | +client.refresh_keys() |
20 | 39 | advertising_token = 'AgAAAANRdREk+IWqqnQkZ2rZdK0TgSUP/owLryysSkUGZJT+Gy551L1WJMAZA/G2B1UMDQ20WAqwwTu6o9TexWyux0lg0HHIbmJjN6IYwo+42KC8ugaR+PX0y18qQ+3yzkxmJ/ee//4IGu/1Yq4AmO4ArXN6CeszPTxByTkysVqyQVNY2A==' |
21 | | -decrypted_token = decrypt(advertising_token, keys) |
| 40 | +decrypted_token = client.decrypt(advertising_token) |
22 | 41 | print(decrypted_token.uid2) |
23 | 42 | ``` |
24 | 43 |
|
25 | | -Additional examples are in the [examples] directory: |
26 | | -* [sample_auto_refresh.py](examples/sample_auto_refresh.py) |
27 | | -* [sample_client.py](examples/sample_client.py) |
28 | | - * Includes an example to encrypt a raw UID2 into an advertising token for UID2 sharing. |
| 44 | +## Usage for Sharers |
| 45 | + |
| 46 | +A UID2 sharer is a participant that wants to share UID2s or EUIDs with another participant. Raw UID2s must be encrypted into UID2 tokens before sending them to another participant. |
| 47 | +For examples of usage, see [sample_sharing.py](examples/sample_sharing.py) and [sample_auto_refresh.py](examples/sample_auto_refresh.py) |
| 48 | + |
| 49 | +``` |
| 50 | +from uid2_client import Uid2ClientFactory |
| 51 | +
|
| 52 | +# for UID2 (for EUID use EuidClientFactory) |
| 53 | +client = Uid2ClientFactory.create('https://prod.uidapi.com', 'my-auth-token', 'my-secret-key') |
| 54 | +client.refresh_keys() |
| 55 | +``` |
| 56 | +Senders: |
| 57 | + |
| 58 | +1. Call the following: |
| 59 | +``` |
| 60 | +encrypted = client.encrypt(raw_uid) |
| 61 | + ``` |
| 62 | +2. If encryption was successful, send the token `encrypted.uid2` to the receiver. |
| 63 | + |
| 64 | +Receivers: |
| 65 | + |
| 66 | +1. Call the following: |
| 67 | +``` |
| 68 | +decrypted = client.decrypt(uid_token) |
| 69 | +``` |
| 70 | +2. If decryption was successful, use the token `decrypted.uid2`. |
29 | 71 |
|
30 | 72 | ## Development |
31 | 73 |
|
@@ -53,13 +95,14 @@ Get access to an interactive shell within the Python 3.6 Docker image: |
53 | 95 | make shell |
54 | 96 | ``` |
55 | 97 |
|
56 | | -## Example Usage |
| 98 | +### Example Usage |
57 | 99 |
|
58 | 100 | To run all the example applications: |
59 | 101 |
|
60 | 102 | ``` |
61 | 103 | make examples BASE_URL=https://prod.uidapi.com AUTH_KEY=my-auth-key SECRET_KEY=my-secret-key \ |
62 | | - AD_TOKEN=AgAAAANRdREk+IWqqnQkZ2rZdK0TgSUP/owLryysSkUGZJT+Gy551L1WJMAZA/G2B1UMDQ20WAqwwTu6o9TexWyux0lg0HHIbmJjN6IYwo+42KC8ugaR+PX0y18qQ+3yzkxmJ/ee//4IGu/1Yq4AmO4ArXN6CeszPTxByTkysVqyQVNY2A== |
| 104 | + AD_TOKEN=AgAAAANRdREk+IWqqnQkZ2rZdK0TgSUP/owLryysSkUGZJT+Gy551L1WJMAZA/G2B1UMDQ20WAqwwTu6o9TexWyux0lg0HHIbmJjN6IYwo+42KC8ugaR+PX0y18qQ+3yzkxmJ/ee//4IGu/1Yq4AmO4ArXN6CeszPTxByTkysVqyQVNY2A== \ |
| 105 | + RAW_UID=JCqmlLXpbbu/jTdpB2a1cNAVs8O72eMXPaQzC9Ic9mE= |
63 | 106 | ``` |
64 | 107 |
|
65 | 108 | Alternatively, you can run specific examples: |
|
0 commit comments