File tree Expand file tree Collapse file tree 4 files changed +25
-4
lines changed
web-integrations/prebid-integrations/client-server Expand file tree Collapse file tree 4 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -8,4 +8,5 @@ UID2_CSTG_SUBSCRIPTION_ID="DMr7uHxqLU"
88UID2_API_KEY = " your-api-key"
99UID2_CLIENT_SECRET = " your-client-secret"
1010UID2_JS_SDK_URL = " https://cdn.integ.uidapi.com/uid2-sdk-4.0.1.js"
11- UID2_JS_SDK_NAME = " __uid2"
11+ UID2_JS_SDK_NAME = " __uid2"
12+ UID2_STORAGE_KEY = " __uid2_advertising_token"
Original file line number Diff line number Diff line change @@ -172,6 +172,7 @@ Enter an opted-out email and click "Generate UID2".
172172| ` UID2_BASE_URL ` | The UID2 Operator endpoint. Use ` http://localhost:8080 ` for local or the integration URL. | ` http://localhost:8080 ` |
173173| ` UID2_API_KEY ` | Your UID2 API key with GENERATOR role. | ` UID2-C-L-124-H8VwqX... ` |
174174| ` UID2_CLIENT_SECRET ` | Your UID2 client secret. | ` NcMgi6Y8C80SlxvV7pYlfcvEIo+2b0508... ` |
175+ | ` UID2_STORAGE_KEY ` | Your localStorage key for storing UID2 tokens. | ` __uid2_advertising_token ` |
175176
176177** Note:** For Docker, use ` http://host.docker.internal:8080 ` instead of ` http://localhost:8080 ` to access services on your host machine.
177178
Original file line number Diff line number Diff line change 99 < script >
1010 console . log ( 'Initializing example.' ) ;
1111
12- const UID2_STORAGE_KEY = '__uid2_advertising_token' ;
12+ let UID2_STORAGE_KEY = '__uid2_advertising_token' ; // Default, will be loaded from server config
1313 let currentIdentity = null ;
1414
1515 // Initialize Prebid.js queue if not already present
137137 location . reload ( ) ;
138138 }
139139
140+ async function loadConfig ( ) {
141+ try {
142+ const response = await fetch ( '/config' ) ;
143+ const config = await response . json ( ) ;
144+ UID2_STORAGE_KEY = config . storageKey ;
145+ console . log ( 'Loaded config from server, storage key:' , UID2_STORAGE_KEY ) ;
146+ } catch ( error ) {
147+ console . log ( 'Failed to load config from server, using default storage key' ) ;
148+ }
149+ }
150+
140151 function loadStoredIdentity ( ) {
141152 const storedToken = localStorage . getItem ( UID2_STORAGE_KEY ) ;
142153 if ( storedToken ) {
154165 }
155166 }
156167
157- function onDocumentReady ( ) {
168+ async function onDocumentReady ( ) {
158169 console . log ( 'Setting up interface handlers.' ) ;
159170
171+ await loadConfig ( ) ;
172+
160173 $ ( '#login' ) . click ( handleLogin ) ;
161174 $ ( '#clear_storage' ) . click ( handleClearStorage ) ;
162175
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ const port = 3052;
1414const uid2BaseUrl = process . env . UID2_BASE_URL || 'https://operator-integ.uidapi.com' ;
1515const uid2ApiKey = process . env . UID2_API_KEY ;
1616const uid2ClientSecret = process . env . UID2_CLIENT_SECRET ;
17+ const uid2StorageKey = process . env . UID2_STORAGE_KEY || '__uid2_advertising_token' ;
1718
1819// Encryption constants
1920const ivLength = 12 ;
@@ -95,9 +96,14 @@ function createEnvelope(payload) {
9596}
9697
9798// ============================================================================
98- // API Endpoint
99+ // API Endpoints
99100// ============================================================================
100101
102+ // GET /config - Returns client configuration
103+ app . get ( '/config' , ( req , res ) => {
104+ res . json ( { storageKey : uid2StorageKey } ) ;
105+ } ) ;
106+
101107// POST /login - Generates UID2 token for email address
102108app . post ( '/login' , async ( req , res ) => {
103109 const jsonEmail = JSON . stringify ( { email : req . body . email } ) ;
You can’t perform that action at this time.
0 commit comments