Skip to content

Commit 9404b4b

Browse files
committed
update readme/makefile
1 parent 6ecfbe4 commit 9404b4b

File tree

3 files changed

+38
-38
lines changed

3 files changed

+38
-38
lines changed

Makefile

Lines changed: 3 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 example_sharing
9+
examples: example_client example_auto_refresh example_sharing example_publisher
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)"
@@ -20,6 +20,8 @@ example_encryption:
2020
example_sharing:
2121
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)"
2222

23+
example_publisher:
24+
docker run -w $(PWD) -v $(PWD):$(PWD) -u `id -u`:`id -g` -e PYTHONPATH=$(PWD) $(DOCKERIMAGE) python3 examples/sample_token_generate_refresh.py "$(BASE_URL)" "$(AUTH_KEY)" "$(SECRET_KEY)"
2325

2426
docker:
2527
docker build -t $(DOCKERIMAGE) -f Dockerfile.dev .

README.md

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ This document includes:
77
* [Requirements](#requirements)
88
* [Install](#install)
99
* [Usage for DSPs](#usage-for-dsps)
10+
* [Usage for Publishers](#usage-for-publishers)
11+
* [Standard Integration](#standard-integration)
12+
* [Server-Only Integration](#server-only-integration)
1013
* [Usage for UID2 Sharers](#usage-for-uid2-sharers)
1114
* [Development](#development)
1215
* [Example Usage](#example-usage)
@@ -41,34 +44,6 @@ decrypted_token = client.decrypt(advertising_token)
4144
print(decrypted_token.uid2)
4245
```
4346

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`.
71-
7247
## Usage for Publishers
7348

7449
1. Create an instance of Uid2PublisherClient
@@ -89,7 +64,7 @@ If you're using standard integration (client and server) (see [UID2 SDK for Java
8964

9065
* Send this identity as a JSON string back to the client (to use in the [identity field](https://unifiedid.com/docs/sdks/client-side-identity#initopts-object-void)) using the following:
9166

92-
`token_generate_response.get_identity_json_string()` //Note: this method returns `None` if the user has opted out, so be sure to handle that case.
67+
`token_generate_response.get_identity_json_string()` //Note: this method returns `None` if the user has opted out, so be sure to handle that case.
9368

9469
### Server-Only Integration
9570

@@ -109,7 +84,7 @@ If you're using server-only integration (see [Publisher Integration Guide, Serve
10984
`identity = IdentityTokens.from_json_string(identityJsonString)`
11085
2. Determine if the identity can be refreshed (that is, the refresh token hasn't expired):
11186

112-
` if not identity or not identity.is_refreshable(): # we must no longer use this identity (for example, remove this identity from the user's session) `
87+
`if not identity or not identity.is_refreshable(): # we must no longer use this identity (for example, remove this identity from the user's session) `
11388
3. Determine if a refresh is needed:
11489

11590
`if identity.is_due_for_refresh()):`
@@ -120,6 +95,35 @@ If you're using server-only integration (see [Publisher Integration Guide, Serve
12095
6. Store `token_refresh_response.get_identity_json_string()` in the user's session. If the user has opted out, this method returns `None`, indicating that the user's identity should be removed from the session. To confirm optout, you can use the `token_refresh_response.is_optout()` function.
12196

12297

98+
99+
## Usage for Sharers
100+
101+
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.
102+
For examples of usage, see [sample_sharing.py](examples/sample_sharing.py) and [sample_auto_refresh.py](examples/sample_auto_refresh.py)
103+
104+
```
105+
from uid2_client import Uid2ClientFactory
106+
107+
# for UID2 (for EUID use EuidClientFactory)
108+
client = Uid2ClientFactory.create('https://prod.uidapi.com', 'my-auth-token', 'my-secret-key')
109+
client.refresh_keys()
110+
```
111+
Senders:
112+
113+
1. Call the following:
114+
```
115+
encrypted = client.encrypt(raw_uid)
116+
```
117+
2. If encryption was successful, send the token `encrypted.uid2` to the receiver.
118+
119+
Receivers:
120+
121+
1. Call the following:
122+
```
123+
decrypted = client.decrypt(uid_token)
124+
```
125+
2. If decryption was successful, use the token `decrypted.uid2`.
126+
123127
## Development
124128

125129
First, build the Docker image with Python 3.6 and all dev dependencies. This is required for all subsequent commands. Run the following:

examples/sample_token_generate_refresh.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,4 @@ def _usage():
5555
json_string = tokens.get_json_string()
5656

5757
print('Status =', status)
58-
print('Advertising Token =', advertising_token)
59-
print('Refresh Token =', refresh_token)
60-
print('Refresh Response Key =', refresh_response_key)
61-
print('Refresh From =', refresh_from)
62-
print('Refresh Expires =', refresh_expires)
63-
print('Identity Expires =', identity_expires)
64-
print('As Json String =', json_string)
58+
print('As Json String =', token_refresh_response.get_identity_json_string())

0 commit comments

Comments
 (0)