You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+67-21Lines changed: 67 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,20 +50,27 @@ If you're using the SDK's HTTP implementation, follow these steps.
50
50
51
51
>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.
52
52
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
+
54
55
#### Standard Integration
55
56
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:
57
58
58
59
* 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:
59
60
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.
61
66
62
67
#### Server-Only Integration
63
68
64
69
If you're using server-only integration (see [Publisher Integration Guide, Server-Only](https://unifiedid.com/docs/guides/custom-publisher-integration)):
65
70
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.
67
74
2. To retrieve the user's UID2 token, use:
68
75
69
76
```
@@ -84,7 +91,9 @@ If you're using server-only integration (see [Publisher Integration Guide, Serve
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.
88
97
89
98
### Advanced Usage
90
99
@@ -102,25 +111,31 @@ If you're using server-only integration (see [Publisher Integration Guide, Serve
102
111
2. Body: `envelope.getEnvelope()`
103
112
>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.
104
113
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)).
106
115
107
116
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:
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)):
114
123
115
124
* 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:
116
125
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.
118
131
119
132
#### Server-Only Integration
120
133
121
134
If you're using server-only integration (see [Publisher Integration Guide, Server-Only](https://unifiedid.com/docs/guides/custom-publisher-integration)):
122
135
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.
124
139
2. To retrieve the user's UID2 token, use:
125
140
126
141
```
@@ -131,13 +146,22 @@ If you're using server-only integration (see [Publisher Integration Guide, Serve
131
146
3. When the user accesses another page, or on a timer, determine whether a refresh is needed:
132
147
1. Retrieve the identity JSON string from the user's session, and then call the following function that generates an `IdentityTokens` object:
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
+
138
159
3. Determine if a refresh is needed:
139
160
140
-
`if (identity.isDueForRefresh()) {..}`
161
+
```
162
+
if (identity.isDueForRefresh()) {..}
163
+
```
164
+
141
165
4. If a refresh is needed, call the [POST token/refresh](https://unifiedid.com/docs/endpoints/post-token-refresh) endpoint, with:
142
166
1. Headers (depending on your HTTP library, this might look something like):
143
167
@@ -146,30 +170,52 @@ If you're using server-only integration (see [Publisher Integration Guide, Serve
146
170
2. Body: `identity.getRefreshToken()`
147
171
5. If the refresh HTTP response status code is 200:
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.
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.
151
180
152
181
## Usage for UID2 Sharers
153
182
154
183
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).
155
184
156
185
1. Use UID2ClientFactory.create() to create an IUID2Client reference:
157
186
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
+
159
191
2. Call IUID2Client.refresh once at startup, and then periodically (for example, every hour):
0 commit comments