Install Auth SDK

Integrate authentication and token management into your Express application with the Wristband SDK.

After setting up Express, install and configure the Wristband ExpressJS SDK in your Express server.


Installation

Install the Wristband Auth SDK using your preferred package manager CLI:

npm install @wristband/express-auth
yarn add @wristband/express-auth
pnpm add @wristband/express-auth

Configuration

For detailed SDK configuration options, view our GitHub documentation for express-auth configuration options.

Create an instance of WristbandAuth in the source root directory of your Express project (e.g.src/wristband-auth.ts):

import { createWristbandAuth } from '@wristband/express-auth';
import { AuthConfig } from './types';

const authConfig: AuthConfig = {
  clientId: 'your-client-id', // replace with your value
  clientSecret: 'your-client-secret', // replace with your value
  dangerouslyDisableSecureCookies: true,
  loginStateSecret: 'your-login-state-secret', // replace with your value
  loginUrl: 'https://your-login-url', // replace with your value
  redirectUri: 'https://your-redirect-uri', // replace with your value
  scopes: ['openid', 'offline_access', 'email', 'profile', 'roles'],
  wristbandApplicationDomain: 'your-wristband-application-domain', // replace with your value
  useTenantSubdomains: false, // replace with your value
  useCustomDomains: false,
};

export const wristbandAuth = createWristbandAuth(authConfig);
const { createWristbandAuth } = require('@wristband/express-auth');

const authConfig = {
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret',
  dangerouslyDisableSecureCookies: true,
  loginStateSecret: 'your-login-state-secret',
  loginUrl: 'https://your-login-url',
  redirectUri: 'https://your-redirect-uri',
  scopes: ['openid', 'offline_access', 'email', 'profile', 'roles'],
  wristbandApplicationDomain: 'your-wristband-application-domain',
  useTenantSubdomains: false,
  useCustomDomains: false,
};

export const wristbandAuth = createWristbandAuth(authConfig);

Regarding configuration for testing your auth integration:

  • The loginUrl and redirectUri are the URL values you provided when creating your Wristband Application and OAuth2 Client, respectively, in the Wristband Dashboard.
  • The clientId, clientSecret, and wristbandApplicationDomain values were presented to you after you created your Wristband Application and OAuth2 Client in the Wristband Dashboard.
  • For Production environments, ensure that dangerouslyDisableSecureCookies is set to false.
  • You can generate a loginStateSecret by running:
    openssl rand -base64 32
    

Next, you'll use your configured Wristband Auth instance to create the necessary authentication endpoints in your Express server.


Whatโ€™s Next