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
+6-198Lines changed: 6 additions & 198 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,8 @@ This document includes:
6
6
*[Who Is this SDK for?](#who-is-this-sdk-for)
7
7
*[Requirements](#requirements)
8
8
*[Install](#install)
9
-
*[Usage for DSPs](#usage-for-dsps)
10
-
*[Usage for Publishers](#usage-for-publishers)
11
-
-[Basic Usage](#basic-usage)
12
-
-[Advanced Usage](#advanced-usage)
13
-
*[Usage for UID2 Sharers](#usage-for-uid2-sharers)
9
+
*[Usage](#usage)
10
+
*[Example usage for DSPs](#example-usage-for-dsps)
14
11
15
12
## Who Is this SDK for?
16
13
@@ -24,198 +21,9 @@ This SDK requires Java version 1.8 or later.
24
21
25
22
To install the SDK, add the `uid2-client` dependency to your project's `pom.xml` file [as shown here](https://central.sonatype.com/artifact/com.uid2/uid2-client).
26
23
27
-
## Usage for DSPs
24
+
## Usage
28
25
29
-
For an example of usage for DSPs, see [com.uid2.client.test.IntegrationExamples](https://github.com/IABTechLab/uid2-client-java/blob/master/src/test/java/com/uid2/client/test/IntegrationExamples.java).
30
-
31
-
## Usage for Publishers
32
-
33
-
As a publisher, there are two ways to use this SDK:
34
-
1.[**Basic Usage**](#basic-usage) is for publishers who want to use this SDK's HTTP implementation (synchronous [OkHttp](https://square.github.io/okhttp/)).
35
-
2.[**Advanced Usage**](#advanced-usage) is for publishers who prefer to use their own HTTP library.
36
-
37
-
For an example application that demonstrates both Basic and Advanced usage, see [Java UID2 Integration Example](https://github.com/UnifiedID2/uid2-examples/tree/main/publisher/uid2-java-test-site#readme).
38
-
39
-
### Basic Usage
40
-
41
-
If you're using the SDK's HTTP implementation, follow these steps.
42
-
43
-
1. Create an instance of PublisherUid2Client as an instance variable.
44
-
45
-
`private final PublisherUid2Client publisherUid2Client = new PublisherUid2Client(UID2_BASE_URL, UID2_API_KEY, UID2_SECRET_KEY);`
46
-
47
-
2. Call a function that takes the user's email address or phone number as input and generates a `TokenGenerateResponse` object. The following example uses an email address:
>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
-
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
-
55
-
#### Standard Integration
56
-
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:
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:
60
-
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.
66
-
67
-
#### Server-Only Integration
68
-
69
-
If you're using server-only integration (see [Publisher Integration Guide, Server-Only](https://unifiedid.com/docs/guides/custom-publisher-integration)):
70
-
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.
if (identity != null) { String advertisingToken = identity.getAdvertisingToken(); }
79
-
```
80
-
4. When the user accesses another page, or on a timer, determine whether a refresh is needed:
81
-
1. Retrieve the identity JSON string from the user's session, and then call the following function that takes the identity information as input and generates an `IdentityTokens` object:
2. Determine if the identity can be refreshed (that is, the refresh token hasn't expired):
85
-
86
-
` if (identity == null || !identity.isRefreshable()) { we must no longer use this identity (for example, remove this identity from the user's session) }`
87
-
3. Determine if a refresh is needed:
88
-
89
-
`if (identity.isDueForRefresh()) {..}`
90
-
5. If needed, refresh the token and associated values:
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.
97
-
98
-
### Advanced Usage
99
-
100
-
1. Create an instance of PublisherUid2Helper as an instance variable:
101
-
102
-
`private final PublisherUid2Helper publisherUid2Helper = new PublisherUid2Helper(UID2_SECRET_KEY);`
103
-
2. Call a function that takes the user's email address or phone number as input and creates a secure request data envelope. See [Encrypting requests](https://unifiedid.com/docs/getting-started/gs-encryption-decryption#encrypting-requests). The following example uses an email address:
3. Using an HTTP client library of your choice, post this envelope to the [POST token/generate](https://unifiedid.com/docs/endpoints/post-token-generate) endpoint, including headers and body:
107
-
1. Headers: Depending on your HTTP library, this might look something like the following:
>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.
113
-
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)).
26
+
For documentation on usage, see the [UID2 SDK for Java Reference Guide](https://unifiedid.com/docs/sdks/uid2-sdk-ref-java).
115
27
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 [JavaScript Standard Integration Guide](https://unifiedid.com/docs/guides/integration-javascript-standard)):
123
-
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:
125
-
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.
131
-
132
-
#### Server-Only Integration
133
-
134
-
If you're using server-only integration (see [Publisher Integration Guide, Server-Only](https://unifiedid.com/docs/guides/custom-publisher-integration)):
135
-
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.
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.
180
-
181
-
## Usage for UID2 Sharers
182
-
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).
184
-
185
-
1. Use UID2ClientFactory.create() to create an IUID2Client reference:
186
-
187
-
```
188
-
private final IUID2Client client = UID2ClientFactory.create(UID2_BASE_URL, UID2_API_KEY, UID2_SECRET_KEY);
189
-
```
190
-
191
-
2. Call IUID2Client.refresh once at startup, and then periodically (for example, every hour):
if (decrypted.isSuccess()) {`use `decrypted.getUid() } else {`check `decrypted.getStatus()` for the failure reason `}
221
-
```
28
+
## Example usage for DSPs
29
+
For an example of usage for DSPs, see [com.uid2.client.test.IntegrationExamples](https://github.com/IABTechLab/uid2-client-java/blob/master/src/test/java/com/uid2/client/test/IntegrationExamples.java).
* @param identityMapInput represents the input required for <a href="https://unifiedid.com/docs/endpoints/post-identity-map">/identity/map</a>
16
+
* @return an IdentityMapResponse instance
17
+
* @throws Uid2Exception if the response did not contain a "success" status, or the response code was not 200, or there was an error communicating with the provided UID2 Base URL
* @param phones a <a href="https://unifiedid.com/docs/getting-started/gs-normalization-encoding#phone-number-normalization">normalized</a> phone number
* @param hashedPhones a <a href="https://unifiedid.com/docs/getting-started/gs-normalization-encoding#phone-number-normalization">normalized</a> and <a href="https://unifiedid.com/docs/getting-started/gs-normalization-encoding#phone-number-hash-encoding">hashed</a> phone number
0 commit comments