Skip to content

Commit e8a299a

Browse files
authored
edits to readme (#54)
* edits to readme to update the Publisher Usage section
1 parent f980dd2 commit e8a299a

File tree

1 file changed

+67
-21
lines changed

1 file changed

+67
-21
lines changed

README.md

Lines changed: 67 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,27 @@ If you're using the SDK's HTTP implementation, follow these steps.
5050

5151
>IMPORTANT: Be sure to call this function only when you have obtained legal basis to convert the user’s [directly identifying information (DII)](https://unifiedid.com/docs/ref-info/glossary-uid#gl-dii) to UID2 tokens for targeted advertising.
5252
53-
>IMPORTANT: Always apply `doNotGenerateTokensForOptedOut()`. This applies `policy=1` in the [/token/generate](https://unifiedid.com/docs/endpoints/post-token-generate#token-generation-policy) call. Support for `policy=0` will be removed soon.
53+
>IMPORTANT: Always apply `doNotGenerateTokensForOptedOut()`. This applies a parameter similar to setting `optout_check=1` in the call to the POST /token/generate endpoint (see [Unencrypted JSON Body Parameters](https://unifiedid.com/docs/endpoints/post-token-generate#unencrypted-json-body-parameters)).
54+
5455
#### Standard Integration
5556

56-
If you're using standard integration (client and server) (see [UID2 SDK for JavaScript Integration Guide](https://unifiedid.com/docs/guides/publisher-client-side)), follow this step:
57+
If you're using standard integration (client and server) (see [JavaScript Standard Integration Guide](https://unifiedid.com/docs/guides/integration-javascript-standard)), follow this step:
5758

5859
* 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:
5960

60-
`tokenGenerateResponse.getIdentityJsonString()` //Note: this method returns `null` if the user has opted out, so be sure to handle that case.
61+
```
62+
tokenGenerateResponse.getIdentityJsonString()
63+
```
64+
65+
>NOTE: If the user has opted out, this method returns `null`, so be sure to handle that case.
6166
6267
#### Server-Only Integration
6368
6469
If you're using server-only integration (see [Publisher Integration Guide, Server-Only](https://unifiedid.com/docs/guides/custom-publisher-integration)):
6570
66-
1. Store this identity as a JSON string in the user's session, using the `tokenGenerateResponse.getIdentityJsonString()` function. This method returns `null` if the user has opted out, so be sure to handle that case.
71+
1. Store this identity as a JSON string in the user's session, using the `tokenGenerateResponse.getIdentityJsonString()` function.
72+
73+
If the user has opted out, this method returns `null`, so be sure to handle that case.
6774
2. To retrieve the user's UID2 token, use:
6875
6976
```
@@ -84,7 +91,9 @@ If you're using server-only integration (see [Publisher Integration Guide, Serve
8491
8592
`TokenRefreshResponse tokenRefreshResponse = publisherUid2Client.refreshToken(identity);`
8693
87-
6. Store `tokenRefreshResponse.getIdentityJsonString()` in the user's session. If the user has opted out, this method returns `null`, indicating that the user's identity should be removed from the session. To confirm optout, you can use the `tokenRefreshResponse.isOptout()` function.
94+
6. Store `tokenRefreshResponse.getIdentityJsonString()` in the user's session.
95+
96+
If the user has opted out, this method returns `null`, indicating that the user's identity should be removed from the session. To confirm optout, you can use the `tokenRefreshResponse.isOptout()` function.
8897
8998
### Advanced Usage
9099
@@ -102,25 +111,31 @@ If you're using server-only integration (see [Publisher Integration Guide, Serve
102111
2. Body: `envelope.getEnvelope()`
103112
>IMPORTANT: Be sure to call this endpoint only when you have obtained legal basis to convert the user’s [directly identifying information (DII)](https://unifiedid.com/docs/ref-info/glossary-uid#gl-dii) to UID2 tokens for targeted advertising.
104113
105-
>IMPORTANT: Always apply `doNotGenerateTokensForOptedOut()`. This applies `policy=1` in the [/token/generate](https://unifiedid.com/docs/endpoints/post-token-generate#token-generation-policy) call. Support for `policy=0` will be removed soon.
114+
>IMPORTANT: Always apply `doNotGenerateTokensForOptedOut()`. This applies a parameter similar to setting `optout_check=1` in the call to the POST /token/generate endpoint (see [Unencrypted JSON Body Parameters](https://unifiedid.com/docs/endpoints/post-token-generate#unencrypted-json-body-parameters)).
106115
107116
4. If the HTTP response status code is _not_ 200, see [Response Status Codes](https://unifiedid.com/docs/endpoints/post-token-generate#response-status-codes) to determine next steps. Otherwise, convert the UID2 identity response content into a `TokenGenerateResponse` object:
108117
109118
`TokenGenerateResponse tokenGenerateResponse = publisherUid2Helper.createTokenGenerateResponse({response body}, envelope);`
110119
111120
#### Standard Integration
112121
113-
If you're using standard integration (client and server) (see [UID2 SDK for JavaScript Integration Guide](https://unifiedid.com/docs/guides/publisher-client-side)):
122+
If you're using standard integration (client and server) (see [JavaScript Standard Integration Guide](https://unifiedid.com/docs/guides/integration-javascript-standard)):
114123
115124
* 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:
116125
117-
`tokenGenerateResponse.getIdentityJsonString() //Note: this method returns null if the user has opted out, so be sure to handle that case.`
126+
```
127+
tokenGenerateResponse.getIdentityJsonString()
128+
```
129+
130+
>NOTE: If the user has opted out, this method returns `null`, so be sure to handle that case.
118131
119132
#### Server-Only Integration
120133
121134
If you're using server-only integration (see [Publisher Integration Guide, Server-Only](https://unifiedid.com/docs/guides/custom-publisher-integration)):
122135
123-
1. Store this identity as a JSON string in the user's session, using: `tokenGenerateResponse.getIdentityJsonString()`. This method returns null if the user has opted out, so be sure to handle that case.
136+
1. Store this identity as a JSON string in the user's session, using: `tokenGenerateResponse.getIdentityJsonString()`.
137+
138+
If the user has opted out, this method returns null, so be sure to handle that case.
124139
2. To retrieve the user's UID2 token, use:
125140
126141
```
@@ -131,13 +146,22 @@ If you're using server-only integration (see [Publisher Integration Guide, Serve
131146
3. When the user accesses another page, or on a timer, determine whether a refresh is needed:
132147
1. Retrieve the identity JSON string from the user's session, and then call the following function that generates an `IdentityTokens` object:
133148
134-
`IdentityTokens identity = IdentityTokens.fromJsonString(identityJsonString);`
149+
```
150+
IdentityTokens identity = IdentityTokens.fromJsonString(identityJsonString);
151+
```
152+
135153
2. Determine if the identity can be refreshed (that is, the refresh token hasn't expired):
136-
137-
` if (identity == null || !identity.isRefreshable()) { we must no longer use this identity (for example, remove this identity from the user's session) }`
154+
155+
```
156+
if (identity == null || !identity.isRefreshable()) { we must no longer use this identity (for example, remove this identity from the user's session) }
157+
```
158+
138159
3. Determine if a refresh is needed:
139160
140-
`if (identity.isDueForRefresh()) {..}`
161+
```
162+
if (identity.isDueForRefresh()) {..}
163+
```
164+
141165
4. If a refresh is needed, call the [POST token/refresh](https://unifiedid.com/docs/endpoints/post-token-refresh) endpoint, with:
142166
1. Headers (depending on your HTTP library, this might look something like):
143167
@@ -146,30 +170,52 @@ If you're using server-only integration (see [Publisher Integration Guide, Serve
146170
2. Body: `identity.getRefreshToken()`
147171
5. If the refresh HTTP response status code is 200:
148172
149-
`TokenRefreshResponse tokenRefreshResponse = PublisherUid2Helper.createTokenRefreshResponse({response body}, identity);`
150-
6. Store `tokenRefreshResponse.getIdentityJsonString()` in the user's session. If the user has opted out, this method returns null, indicating that the user's identity should be removed from the session. To confirm optout, you can use the `tokenRefreshResponse.isOptout()` function.
173+
```
174+
TokenRefreshResponse tokenRefreshResponse = PublisherUid2Helper.createTokenRefreshResponse({response body}, identity);
175+
```
176+
177+
6. Store `tokenRefreshResponse.getIdentityJsonString()` in the user's session.
178+
179+
If the user has opted out, this method returns null, indicating that the user's identity should be removed from the session. To confirm optout, you can use the `tokenRefreshResponse.isOptout()` function.
151180
152181
## Usage for UID2 Sharers
153182
154183
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. For an example of usage, see [com.uid2.client.test.IntegrationExamples](https://github.com/IABTechLab/uid2-client-java/blob/master/src/test/java/com/uid2/client/test/IntegrationExamples.java) (runSharingExample method).
155184
156185
1. Use UID2ClientFactory.create() to create an IUID2Client reference:
157186
158-
`private final IUID2Client client = UID2ClientFactory.create(UID2_BASE_URL, UID2_API_KEY, UID2_SECRET_KEY);`
187+
```
188+
private final IUID2Client client = UID2ClientFactory.create(UID2_BASE_URL, UID2_API_KEY, UID2_SECRET_KEY);
189+
```
190+
159191
2. Call IUID2Client.refresh once at startup, and then periodically (for example, every hour):
160192
161-
`client.refresh();`
193+
```
194+
client.refresh();
195+
```
196+
162197
3. Senders:
163198
1. Call the following:
164199
165-
`EncryptionDataResponse encrypted = client.encrypt(rawUid);`
200+
```
201+
EncryptionDataResponse encrypted = client.encrypt(rawUid);
202+
```
203+
166204
2. If encryption succeeded, send the UID2 token to the receiver:
167205
168-
`if (encrypted.isSuccess()) {` send `encrypted.getEncryptedData()` to receiver`} else {`check `encrypted.getStatus()` for the failure reason}
206+
```
207+
if (encrypted.isSuccess()) {` send `encrypted.getEncryptedData()` to receiver`} else {`check `encrypted.getStatus()` for the failure reason}
208+
```
209+
169210
4. Receivers:
170211
1. Call the following:
171212
172-
`DecryptionResponse decrypted = client.decrypt(uidToken);`
213+
```
214+
DecryptionResponse decrypted = client.decrypt(uidToken);
215+
```
216+
173217
2. If decryption succeeded, use the raw UID2:
174218
175-
`if (decrypted.isSuccess()) {`use `decrypted.getUid() } else {`check `decrypted.getStatus()` for the failure reason `}`
219+
```
220+
if (decrypted.isSuccess()) {`use `decrypted.getUid() } else {`check `decrypted.getStatus()` for the failure reason `}
221+
```

0 commit comments

Comments
 (0)