An example application demonstrating to use the WorkOS Node SDK to power Directory Sync.
Node.js version 10+
-
Clone the main repo and install dependencies for the app you'd like to use:
# HTTPS git clone https://github.com/workos/node-example-applications.gitor
# SSH git clone git@github.com:workos/node-example-applications.git -
Navigate to Directory Sync app within the cloned repo.
$ cd node-example-applications/node-directory-sync-example -
Install the dependencies.
$ npm install
- Grab your API Key.
- Create a
.envfile at the root of the project and populate with the following environment variables (using values found above):
WORKOS_API_KEY = your_api_key_herenpm startHead to http://localhost:8000/ to navigate your directories!
Ngrok is a simple application that allows you to map a local endpoint to a public endpoint.
The application will run on http://localhost:8000. Ngrok will create a tunnel to the application so we can receive webhooks from WorkOS.
./ngrok http 8000Log into the WorkOS Dashboard and add a Webhook endpoint with the public ngrok URL with /webhooks appended.
The local application is listening for webhook requests at http://localhost:8000/webhooks
In order for the SDK to validate that WorkOS webhooks, locate the Webhook secret from the dashboard.
Then populate the following environment variable in your .env file at the root of the project.
WORKOS_WEBHOOK_SECRET=your_webhook_secretIf you get stuck and aren't able to resolve the issue by reading our WorkOS Directory Sync documentation, API reference, or tutorials, you can reach out to us at support@workos.com and we'll lend a hand.