> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.itential.com/adapters/authentication/patterns/dynamic-token-per-domain/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.itential.com/_mcp/server. # Dynamic token per domain > How to pass a domain dynamically on each request so the adapter authenticates within the correct domain for that call. This system authenticates on a per-domain basis. Every call must be authenticated within the domain it targets, and that domain changes per request. Because the domain is dynamic, it must be passed into the adapter method on each call and injected into the `authData` object of the request. The adapter library is already prepared to handle this — no changes to the library are needed — but code changes in `adapter.js` and `pronghorn.json` are required. ## Configuration ### adapter.js Add a parameter to each method that needs domain-based authentication (in this example, `domainVar`) and set it in the `authData` object on the `reqObj`. The adapter library will include this data in the authentication request body. ```javascript getMyData(query, domainVar, callback) { // ... const reqObj = { payload: { garbage: 'need since post' }, uriPathVars: [groupId, deviceId], uriQuery: { name: 'anyname' }, uriOptions: { page: 2 }, addlHeaders: { audit: 'turnOn' }, authData: { domain: domainVar }, callProperties: { stub: true, request: { attempt_timeout: 60000 } }, filter: '[*name=doggie]' }; ``` ### pronghorn.json Add the corresponding input parameter to each affected method in `pronghorn.json` so the domain value can be passed in from anItential Platform workflow. ```json { "name": "getMyData", "summary": "get my data from blah", "description": "get my data from blah", "input": [ { "name": "query", "type": "object", "info": "object containing query fields", "required": false, "schema": { "title": "query", "type": "object" } }, { "name": "domainVar", "type": "string", "info": "the domain to send for authentication", "required": true, "schema": { "title": "domainVar", "type": "string" } } ], "output": { "name": "result", "type": "object", "description": "A JSON Object containing status, code and the result" }, "route": { "verb": "POST", "path": "/getMyData" }, "roles": ["admin"], "task": true } ``` > How to pass a domain dynamically on each request so the adapter authenticates within the correct domain for that call.