An example application demonstrating to use the WorkOS Node SDK to authenticate users via SSO.
Node.js version 10+
-
In your CLI, navigate to the directory into which you want to clone this git repo.
$ cd ~/Desktop/
-
Clone this repo and install dependencies:
# HTTPS git clone https://github.com/workos-inc/node-sso-example.git
or
# SSH git clone https://github.com/workos-inc/node-sso-example.git && cd node-sso-example && npm install
-
Navigate to the cloned repo.
$ cd node-sso-example
-
Install the dependencies.
$ npm install
- Grab your API Key and Client ID from the WorkOS Dashboard. Create a
.env
file at the root of the project, and store these like so:WORKOS_API_KEY=sk_xxxxxxxxxxxxx WORKOS_CLIENT_ID=project_xxxxxxxxxxxx
-
Follow the SSO authentication flow instructions to create a new SSO connection in your WorkOS dashboard.
-
Add
http://localhost:3000/callback
as a Redirect URI in the Configuration section of the Dashboard. -
Update
routes/index.js
with the Connection domain (or Connection ID).
- Start the server and head to `http://localhost:3000/ to begin the login flow!
npm start
If you get stuck and aren't able to resolve the issue by reading our WorkOS Node SDK documentation, API reference, or tutorials, you can reach out to us at support@workos.com and we'll lend a hand.