Skip to content

Commit d48b5a9

Browse files
committed
splitting branch
1 parent 6c50fde commit d48b5a9

13 files changed

+20
-680
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test:
66
shell:
77
docker run -it -w $(PWD) -v $(PWD):$(PWD) -u `id -u`:`id -g` $(DOCKERIMAGE) /bin/bash
88

9-
examples: example_client example_auto_refresh
9+
examples: example_client example_auto_refresh example_sharing
1010

1111
example_client:
1212
docker run -w $(PWD) -v $(PWD):$(PWD) -u `id -u`:`id -g` -e PYTHONPATH=$(PWD) $(DOCKERIMAGE) python3 examples/sample_client.py "$(BASE_URL)" "$(AUTH_KEY)" "$(SECRET_KEY)" "$(AD_TOKEN)"
@@ -17,6 +17,10 @@ example_auto_refresh:
1717
example_encryption:
1818
docker run -w $(PWD) -v $(PWD):$(PWD) -u `id -u`:`id -g` -e PYTHONPATH=$(PWD) $(DOCKERIMAGE) python3 examples/sample_encryption.py "$(BASE_URL)" "$(AUTH_KEY)" "$(SECRET_KEY)" "$(AD_TOKEN)" "Hello World!"
1919

20+
example_sharing:
21+
docker run -w $(PWD) -v $(PWD):$(PWD) -u `id -u`:`id -g` -e PYTHONPATH=$(PWD) $(DOCKERIMAGE) python3 examples/sample_sharing.py "$(BASE_URL)" "$(AUTH_KEY)" "$(SECRET_KEY)" "$(RAW_UID)"
22+
23+
2024
docker:
2125
docker build -t $(DOCKERIMAGE) -f Dockerfile.dev .
2226

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@ Connect to the UID2 service, refresh the encryption keys, and then use the keys
1515
```
1616
from uid2_client import Uid2Client, decrypt
1717
18-
client = Uid2Client('https://prod.uidapi.com', 'my-auth-token', 'my-secret-key')
18+
client = Uid2Client('https://prod.uidapi.com', 'my-auth-token', 'my-secret-key', IdentityScope.UID2)
1919
keys = client.refresh_keys()
2020
advertising_token = 'AgAAAANRdREk+IWqqnQkZ2rZdK0TgSUP/owLryysSkUGZJT+Gy551L1WJMAZA/G2B1UMDQ20WAqwwTu6o9TexWyux0lg0HHIbmJjN6IYwo+42KC8ugaR+PX0y18qQ+3yzkxmJ/ee//4IGu/1Yq4AmO4ArXN6CeszPTxByTkysVqyQVNY2A=='
21-
decrypted_token = decrypt(advertising_token, keys)
21+
decrypted_token = client.decrypt(advertising_token, keys)
2222
print(decrypted_token.uid2)
2323
```
2424

2525
Additional examples are in the [examples] directory:
2626
* [sample_auto_refresh.py](examples/sample_auto_refresh.py)
2727
* [sample_client.py](examples/sample_client.py)
28-
* Includes an example to encrypt a raw UID2 into an advertising token for UID2 sharing.
28+
* Example for DSPs (decryption of tokens)
29+
* [sample_sharing.py](examples/sample_sharing.py)
30+
* Example for Sharers (decryption/encryption of tokens/uids)
2931

3032
## Development
3133

@@ -59,7 +61,8 @@ To run all the example applications:
5961

6062
```
6163
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==
64+
AD_TOKEN=AgAAAANRdREk+IWqqnQkZ2rZdK0TgSUP/owLryysSkUGZJT+Gy551L1WJMAZA/G2B1UMDQ20WAqwwTu6o9TexWyux0lg0HHIbmJjN6IYwo+42KC8ugaR+PX0y18qQ+3yzkxmJ/ee//4IGu/1Yq4AmO4ArXN6CeszPTxByTkysVqyQVNY2A== \
65+
RAW_UID=JCqmlLXpbbu/jTdpB2a1cNAVs8O72eMXPaQzC9Ic9mE=
6366
```
6467

6568
Alternatively, you can run specific examples:

examples/sample_client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
from uid2_client.identity_scope import IdentityScope
77

88
# this sample client decrypts an advertising token into a raw UID2
9-
# and then encrypts it into a new advertising token
10-
# to demonstrate decryption (for DSPs and sharers) and encryption (sharers only).
9+
# to demonstrate decryption for DSPs
1110

1211
def _usage():
1312
print('Usage: python3 sample_client.py <base_url> <auth_key> <secret_key> <ad_token>', file=sys.stderr)

examples/sample_sharing.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
from uid2_client import encrypt
66
from uid2_client.identity_scope import IdentityScope
77

8+
# this sample client encrypts and decrypts a uid2 to a sharing token
9+
# to demonstrate encryption and decryption for sharers
10+
811
def _usage():
912
print('Usage: python3 sample_encryption.py <base_url> <auth_key> <secret_key> <raw_uid>', file=sys.stderr)
1013
sys.exit(1)
@@ -20,11 +23,13 @@ def _usage():
2023

2124
client = Uid2Client(base_url, auth_key, secret_key, IdentityScope.UID2)
2225
keys = client.refresh_keys()
23-
2426
new_ad_token = client.encrypt(raw_uid, keys)
27+
2528
print('New Ad Token =', new_ad_token)
29+
2630
decrypt_result = client.decrypt(new_ad_token, keys)
31+
2732
print('Decrypted UID2 =', decrypt_result.uid2)
2833
print('Established =', decrypt_result.established)
2934
print('Site ID =', decrypt_result.site_id)
30-
print('Site Key Site ID =', decrypt_result.site_key_site_id)
35+
print('Site Key Site ID =', decrypt_result.site_key_site_id)

examples/sample_token_generate_refresh.py

Lines changed: 0 additions & 63 deletions
This file was deleted.

tests/publisher_tests.py

Lines changed: 0 additions & 194 deletions
This file was deleted.

uid2_client/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,5 @@
1212
from .client import *
1313
from .encryption import *
1414
from .keys import *
15-
from .publisher_client import *
16-
from .token_generate_input import *
1715

1816

0 commit comments

Comments
 (0)