Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For each API you protect Data Theorem provides a unique identifier which authenticates the SDK when it communicates with our services. The client id we provide can be set in two way, either via an environment variable DT_API_PROTECT_CLIENT_ID or by passing it directly to the middleware.

The client id is in a file named client_id in the sdk bundle you downloaded.

Example setting the client id via ENV Var

> source ./client_id && npm run

Setting the environment variable is the preferred way, but if you need to pass it to the middleware, here is how to do that:

Example passing

...

clientId to Express middleware

Code Block
languagejs
const express = require('express');
const apiprotect = require('apiprotect');
const settings = require('settings')l

const app = express();

// Register body parsing middlware then APIProtect middlware
app.use(express.json());
app.use(apiprotect(settings.clientId)); // ClientId passed as param

...