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
+34-29Lines changed: 34 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,28 @@
1
-
# UID2 Java SDK
1
+
# UID2 SDK for Java
2
2
3
3
The UID 2 Project is subject to the IAB Tech Lab Intellectual Property Rights (IPR) Policy, and is managed by the IAB Tech Lab Addressability Working Group and [Privacy & Rearc Commit Group](https://iabtechlab.com/working-groups/privacy-rearc-commit-group/). Please review the [governance rules](https://github.com/IABTechLab/uid2-core/blob/master/Software%20Development%20and%20Release%20Procedures.md).
4
4
5
5
This document includes:
6
-
*[Who is this SDK for?](#who-is-this-sdk-for)
6
+
*[Who Is this SDK for?](#who-is-this-sdk-for)
7
7
*[Requirements](#requirements)
8
-
*[Installation](#installation)
8
+
*[Install](#install)
9
9
*[Usage for DSPs](#usage-for-dsps)
10
10
*[Usage for Publishers](#usage-for-publishers)
11
11
-[Basic Usage](#basic-usage)
12
12
-[Advanced Usage](#advanced-usage)
13
-
*[## Usage for UID Sharers](#usage-for-uid-sharers)
13
+
*[## Usage for UID2 Sharers](#usage-for-uid2-sharers)
14
14
15
-
## Who is this SDK for?
16
-
This SDK simplifies integration with UID2 for Publishers, DSPs, and UID Sharers, as described in the [UID2 Integration Guides](https://github.com/IABTechLab/uid2docs/blob/main/api/v2/guides/summary-guides.md).
15
+
## Who Is this SDK for?
16
+
17
+
This SDK simplifies integration with UID2 for Publishers, DSPs, and UID Sharers, as described in [UID2 Integration Guides](https://unifiedid.com/docs/category/integration-guides).
17
18
18
19
## Requirements
19
20
20
-
*This SDK requires Java version 1.8 or later.
21
+
This SDK requires Java version 1.8 or later.
21
22
22
-
## Installation
23
+
## Install
23
24
24
-
Add this dependency to your project's POM:
25
+
To install the SDK, add this dependency to your project's `pom.xml` file:
25
26
26
27
```
27
28
<dependency>
@@ -38,10 +39,10 @@ For an example of usage for DSPs, see [com.uid2.client.test.IntegrationExamples]
38
39
## Usage for Publishers
39
40
40
41
As a publisher, there are two ways to use this SDK:
41
-
1.[**Basic Usage**](#basic-usage) is for publishers who are happy to use this SDK's HTTP implementation (synchronous [OkHttp](https://square.github.io/okhttp/)).
42
+
1.[**Basic Usage**](#basic-usage) is for publishers who want to use this SDK's HTTP implementation (synchronous [OkHttp](https://square.github.io/okhttp/)).
42
43
2.[**Advanced Usage**](#advanced-usage) is for publishers who prefer to use their own HTTP library.
43
44
44
-
For an example application that demonstrates both Basic and Advanced usage, see [uid2-examples](https://github.com/UnifiedID2/uid2-examples/tree/main/publisher/uid2-java-test-site).
45
+
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).
45
46
46
47
### Basic Usage
47
48
@@ -57,13 +58,15 @@ If you're using the SDK's HTTP implementation, follow these steps.
57
58
58
59
#### Standard Integration
59
60
60
-
If you're using [standard (client and server) integration](https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/guides/publisher-client-side.md), follow this step:
61
+
If you're using standard integration (client and server) (see [Client-Side JavaScript SDK Integration Guide](https://unifiedid.com/docs/guides/publisher-client-side)), follow this step:
62
+
63
+
* 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:
61
64
62
-
* Send this identity as a JSON string back to the client (to use in the [identity field](https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/sdks/client-side-identity.md#initopts-object-void)) using:`identity.getJsonString()`
65
+
`identity.getJsonString()`
63
66
64
67
#### Server-Only Integration
65
68
66
-
If you're using [server-only integration](https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/guides/custom-publisher-integration.md):
69
+
If you're using server-only integration (see [Publisher Integration Guide, Server-Only (Without SDK)](https://unifiedid.com/docs/guides/custom-publisher-integration)):
67
70
68
71
1. Store this identity as a JSON string in the user's session, using the `identity.getJsonString()` function.
69
72
2. To use the user's UID2 token, use the `identity.getAdvertisingToken()` function.
@@ -81,37 +84,39 @@ If you're using [server-only integration](https://github.com/UnifiedID2/uid2docs
5.You should then 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 their session. (Optout can be confirmed via `tokenRefreshResponse.isOptout()`.)
87
+
5.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.
85
88
86
89
### Advanced Usage
87
90
88
91
1. Create an instance of PublisherUid2Helper as an instance variable:
89
92
90
93
`private final PublisherUid2Helper publisherUid2Helper = new PublisherUid2Helper(UID2_SECRET_KEY);`
91
-
2. When the user has authenticated, and has authorized the creation of a UID2, 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://github.com/IABTechLab/uid2docs/blob/main/api/v2/getting-started/gs-encryption-decryption.md#encrypting-requests). The following example uses an email address:
94
+
2. When the user has authenticated, and has authorized the creation of a UID2, 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 [/v2/token/generate](https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/endpoints/post-token-generate.md) endpoint, including headers and body:
97
+
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:
95
98
1. Headers: Depending on your HTTP library, this might look something like the following:
4. If the HTTP response status code is _not_ 200, see [Response Status Codes](https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/endpoints/post-token-generate.md#response-status-codes) to determine next steps. Otherwise, convert the UID2 identity response content into an `IdentityTokens` object:
103
+
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 an `IdentityTokens` object:
If you're using [standard (client and server) integration](https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/guides/publisher-client-side.md):
109
+
If you're using standard integration (client and server) (see [Client-Side JavaScript SDK Integration Guide](https://unifiedid.com/docs/guides/publisher-client-side)):
110
+
111
+
* 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:
107
112
108
-
1. Send this identity as a JSON string back to the client (to use in the [identity field](https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/sdks/client-side-identity.md#initopts-object-void)) using:`identity.getJsonString()`
113
+
`identity.getJsonString()`
109
114
110
115
#### Server-Only Integration
116
+
If you're using server-only integration (see [Publisher Integration Guide, Server-Only (Without SDK)](https://unifiedid.com/docs/guides/custom-publisher-integration)):
111
117
112
-
If you're using [server-only integration](https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/guides/custom-publisher-integration.md):
113
-
1. Store this identity as a JSON string in the user's session, using: `identity.getJsonString()`
114
-
2. To use the user's UID2 token, use `identity.getAdvertisingToken()`
118
+
1. Store this identity as a JSON string in the user's session, using: `identity.getJsonString()`.
119
+
2. To use the user's UID2 token, use `identity.getAdvertisingToken()`.
115
120
116
121
3. When the user accesses another page, or on a timer, determine whether a refresh is needed:
117
122
1. Retrieve the identity JSON string from the user's session, and then call the following function that generates an `IdentityTokens` object:
@@ -123,7 +128,7 @@ If you're using [server-only integration](https://github.com/UnifiedID2/uid2docs
123
128
3. Determine if a refresh is needed:
124
129
125
130
`if (identity.isDueForRefresh()) {..}`
126
-
4. If a refresh is needed, call the [POST token/refresh](https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/endpoints/post-token-refresh.md) endpoint, with:
131
+
4. If a refresh is needed, call the [POST token/refresh](https://unifiedid.com/docs/endpoints/post-token-refresh) endpoint, with:
127
132
1. Headers (depending on your HTTP library, this might look something like):
6.You should then 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 their session (you can confirm user opt-out with the `tokenRefreshResponse.isOptout()` function).
140
+
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.
136
141
137
-
## Usage for UID Sharers
142
+
## Usage for UID2 Sharers
138
143
139
-
A UID2 Sharer is a participant that wants to share UID2s or EUIDs with another participant. Raw UIDs must be encrypted into UID 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).
144
+
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).
140
145
141
146
1. Use UID2ClientFactory.create() to create an IUID2Client reference:
142
147
@@ -148,13 +153,13 @@ A UID2 Sharer is a participant that wants to share UID2s or EUIDs with another p
Copy file name to clipboardExpand all lines: src/main/java/com/uid2/client/EnvelopeV2.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,8 @@ public class EnvelopeV2 {
8
8
}
9
9
10
10
/**
11
-
* @return an encrypted request envelope which can be used in the POST body of a <a href="https://github.com/UnifiedID2/uid2docs/tree/main/api/v2/endpoints">UID2 endpoint</a>.
12
-
* See <a href="https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/encryption-decryption.md#encrypted-request-envelope">Encrypted Request Envelope</a>
11
+
* @return an encrypted request envelope which can be used in the POST body of a <a href="https://unifiedid.com/docs/endpoints/summary-endpoints">UID2 endpoint</a>.
12
+
* See <a href="https://unifiedid.com/docs/getting-started/gs-encryption-decryption#encrypted-request-envelope">Encrypted Request Envelope</a>
Copy file name to clipboardExpand all lines: src/main/java/com/uid2/client/IdentityTokens.java
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ static public IdentityTokens fromJsonString(String jsonString) {
27
27
}
28
28
29
29
/**
30
-
* @return whether this identity is due to be refreshed. If true, a call to <a href="https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/endpoints/post-token-refresh.md">/token/refresh</a> is due.
30
+
* @return whether this identity is due to be refreshed. If true, a call to <a href="https://unifiedid.com/docs/endpoints/post-token-refresh">/token/refresh</a> is due.
31
31
*/
32
32
publicbooleanisDueForRefresh() {
33
33
returnisDueForRefreshImpl(Instant.now());
@@ -39,13 +39,13 @@ public boolean isDueForRefresh() {
* @return the refresh token. This is used as the POST body in <a href="https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/endpoints/post-token-refresh.md">/token/refresh</a>
42
+
* @return the refresh token. This is used as the POST body in <a href="https://unifiedid.com/docs/endpoints/post-token-refresh">/token/refresh</a>
* @return the identity as represented by a JSON string. This should be sent back to the client if using <a href="https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/guides/publisher-client-side.md">standard integration</a>,
48
-
* or stored in the user's session if using <a href="https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/guides/custom-publisher-integration.md">Server-Only integration.</a>
47
+
* @return the identity as represented by a JSON string. This should be sent back to the client if using <a href="https://unifiedid.com/docs/guides/publisher-client-side">standard integration</a>,
48
+
* or stored in the user's session if using <a href="https://unifiedid.com/docs/guides/custom-publisher-integration">Server-Only integration.</a>
49
49
*/
50
50
publicStringgetJsonString() {returnjsonString;} //this ensures we make newly added fields available, even before this class is updated.
* @param tokenGenerateInput represents the input required for <a href="https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/endpoints/post-token-generate.md#unencrypted-json-body-parameters">/token/generate</a>
21
+
* @param tokenGenerateInput represents the input required for <a href="https://unifiedid.com/docs/endpoints/post-token-generate#unencrypted-json-body-parameters">/token/generate</a>
22
22
* @return an IdentityTokens instance
23
23
* @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
Copy file name to clipboardExpand all lines: src/main/java/com/uid2/client/PublisherUid2Helper.java
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -23,8 +23,8 @@ public PublisherUid2Helper(String base64SecretKey) {
23
23
}
24
24
25
25
/**
26
-
* @param tokenGenerateInput represents the input required for <a href="https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/endpoints/post-token-generate.md#unencrypted-json-body-parameters">/token/generate</a>
27
-
* @return an EnvelopeV2 instance to use in the POST body of <a href="https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/endpoints/post-token-generate.md">/token/generate</a>
26
+
* @param tokenGenerateInput represents the input required for <a href="https://unifiedid.com/docs/endpoints/post-token-generate#unencrypted-json-body-parameters">/token/generate</a>
27
+
* @return an EnvelopeV2 instance to use in the POST body of <a href="https://unifiedid.com/docs/endpoints/post-token-generate">/token/generate</a>
@@ -34,7 +34,7 @@ public EnvelopeV2 createEnvelopeForTokenGenerateRequest(TokenGenerateInput token
34
34
}
35
35
36
36
/**
37
-
* @param response the response body returned by a call to <a href="https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/endpoints/post-token-generate.md">/token/generate</a>
37
+
* @param response the response body returned by a call to <a href="https://unifiedid.com/docs/endpoints/post-token-generate">/token/generate</a>
38
38
* @param envelope the EnvelopeV2 instance returned by {@link #createEnvelopeForTokenGenerateRequest}
39
39
* @return an IdentityTokens instance
40
40
* @throws Uid2Exception if the response did not contain a "success" status
@@ -51,7 +51,7 @@ public IdentityTokens createIdentityfromTokenGenerateResponse(String response, E
51
51
}
52
52
53
53
/**
54
-
* @param encryptedResponse the response body returned by a call to <a href="https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/endpoints/post-token-refresh.md">/token/refresh</a>
54
+
* @param encryptedResponse the response body returned by a call to <a href="https://unifiedid.com/docs/endpoints/post-token-refresh">/token/refresh</a>
55
55
* @param currentIdentity the current IdentityTokens instance, typically retrieved from a user's session
56
56
* @return the refreshed IdentityTokens instance (with a new advertising token and updated expiry times). Typically, this will be used to replace the current identity in the user's session
Copy file name to clipboardExpand all lines: src/main/java/com/uid2/client/TokenRefreshResponse.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ public boolean isSuccess() {
21
21
}
22
22
23
23
/**
24
-
* @return whether the user has opted out. See <a href="https://github.com/UnifiedID2/uid2docs/blob/main/api/v2/endpoints/post-token-refresh.md#optout">Optout</a>
24
+
* @return whether the user has opted out. See <a href="https://unifiedid.com/docs/endpoints/post-token-refresh#optout">Optout</a>
0 commit comments