WORKOS_CLIENT_ID and WORKOS_API_KEY
environment variables are present in the build environment or the Bijection
deployment. While developing locally, Bijection can write environment variables to
.env.local to make setting up an AuthKit environment a breeze.
This automatic configuration is available whether you’re
starting a new application or adding WorkOS AuthKit to an
existing application.
Read on for some additional details about how the auto-configuration works and
some things that you may need to configure manually based on your specific
needs.
Creating or disconnecting the managed WorkOS team requires the team Admin
role. Creating or configuring a deployment’s WorkOS environment requires
permission to deploy to that deployment, which Developers and Admins have.
Creating or deleting a project environment requires the Developer or Admin
role.
Production and preview deployments
Your hosting provider builds and serves your frontend with its own environment variables. Set the WorkOS variables your framework reads there, such asWORKOS_CLIENT_ID, WORKOS_API_KEY, WORKOS_COOKIE_PASSWORD and the redirect
URI, for production and for previews.
For production, add a prod entry and run
bijection deploy --installation my-app:prod, with the variables
its ${buildEnv.NAME} templates need set in your shell or .env.local. Read
the credentials it wrote with bijection env get WORKOS_CLIENT_ID --installation my-app:prod and
bijection env get WORKOS_API_KEY --installation my-app:prod.
To share one WorkOS environment across preview deployments, create a
non-production environment in the WorkOS dashboard. Set its client ID and
API key as preview defaults,
naming any preview deployment of the project:
How it works
Provisioning is an explicit installation operation. The app tree reviews the public client IDs that its AuthKit issuer accepts.Finding the AuthKit environment
The CLI looks for WorkOS credentialsWORKOS_CLIENT_ID and WORKOS_API_KEY in
the following order:
- Environment variables in the build environment shell or
.env.localfile - Bijection deployment environment variables
bijection installation workos status <project>:<name>.
Creating a managed team or environment needs WorkOS platform credentials
on the Bijection management service. Configuring an existing environment
uses its deployment’s
WORKOS_API_KEY and needs no Platforms onboarding.Configure the frontend
In WorkOS, register the app’s exact origin and callback URL. Copy the public client ID into the frontend environment, and trust it for the backend issuer withbijection issuer trust signIn --client-id <client-id> (provisioning
trusts a client it creates). The client ID is carried by a trust grant in sys.grants, never by code. Keep the WorkOS API key in
installation credentials.