SDK for C# / .NET reference guide
You can use the SDK for C# / .NET on the server side to encrypt raw UID2s to create UID2 tokens for sharing, and to decrypt UID2 tokens to access the raw UID2.
Overview
The functions outlined here define the information that you'll need to configure or can retrieve from the library. The parameters and property names defined below are pseudocode. Actual parameters and property names vary by language but will be similar to the information outlined here.
Functionality
This SDK simplifies integration with UID2 for any DSPs or UID2 sharers who are using C# / .NET for their server-side coding. The following table shows the functions it supports.
| Encrypt Raw UID2 to UID2 Token for Sharing | Decrypt UID2 Token to Raw UID2 | Generate UID2 Token from DII | Refresh UID2 Token | Map DII to Raw UID2s | Monitor Rotated Salt Buckets |
|---|---|---|---|---|---|
| ✅ | ✅ | — | — | — | — |
UID2 account setup
To integrate with UID2, you'll need to have a UID2 account. If you haven't yet created an account, first follow the steps described on the Account setup page.
API permissions
When initial account setup is complete, if you're a publisher, advertiser, or data provider, you'll receive instructions and a link to access the UID2 Portal, where you can:
- Generate credentials for your account.
- Optionally, configure other values, such as setting up information about team members.
You'll be granted permission to use specific functions offered by the SDK, and given credentials for that access. Bear in mind that there might be functions in the SDK that you don't have permission to use. For details, see API permissions.
If you're a DSP, we'll send credentials to you.
Version
The library uses .NET Standard 2.1. unit tests. The sample app uses .NET 5.0.
GitHub repository/binary
This SDK is in the following open-source GitHub repository:
The binary is published in this location:
Initialization
DSPs should create an instance of the BidstreamClient class. Sharers should create an instance of the SharingClient class.
You will need to provide the values necessary for the SDK to authenticate with the UID2 service.
| Parameter | Description |
|---|---|
endpoint | The endpoint for the UID2 service. See Environments. |
authKey | The API key. See UID2 credentials. |
secretKey | The client secret. See UID2 credentials. |
Interface
The BidstreamClient class allows you to decrypt UID2 tokens into raw UID2s.
For details on the bidding logic for handling user opt-outs, see DSP integration guide.
The SharingClient class allows you to encrypt raw UID2s into UID2 tokens and decrypt UID2 tokens into raw UID2s.
When you use an SDK, you do not need to store or manage decryption keys.
Encryption response content
When encrypting with the SharingClient, the SDK returns the following information:
| Property | Description |
|---|---|
Status | The encryption result status. For a list of possible values and definitions, see Encryption response statuses. |
EncryptedData | The encrypted UID2 token. |