Set up OAuth
Fern-managed authentication integrated with your login system
Fern-managed authentication integrated with your login system
This feature is available only for the Enterprise plan. To get started, reach out to support@buildwithfern.com.
With OAuth, Fern manages the auth flow for you. You give Fern access to your OAuth provider, and Fern handles the fern_token cookie that integrates your docs with your existing login system. Like JWT, OAuth enables:
fern_token cookie containing the user’s access and credentials.Go to your OAuth provider’s dashboard and create a new web application client.
Allowlist the following callback in your OAuth provider:
https://<your-domain>/api/fern-docs/oauth2/callback.
Replace <your-domain> with your Fern Docs domain. If you use both a .docs.buildwithfern.com and a custom domain, allowlist both.
Send the following to support@buildwithfern.com or your dedicated Slack channel:
https://<your-oauth-tenant>/oauth2/authorize)https://<your-oauth-tenant>/oauth2/token)openid, profile, email)https://<your-domain>)https://<your-oauth-tenant>/oauth2/logout)If your client is connected to an API, you may need to specify an audience in the authentication request.
The updated authorization URL may look like this: https://<your-oauth-tenant>/oauth2/authorize?audience=<your-api-identifier>
Fern will configure OAuth on your site. You’ll receive a notification when authentication is ready.
Once OAuth is working, configure the features you need:
Add a custom claim to your OAuth provider’s token response so that Fern can determine each user’s roles. The resulting token response should look something like this:
Using a claim other than roles
Some OAuth providers have strict requirements for custom claims. If you need to use a claim other than roles, reach out to Fern and specify which claim should be parsed for the user’s roles.
To add a custom claim to Auth0, you need to create a custom action. This action will be used to add the custom claim to the token response.
Once your token response includes roles, define those roles in docs.yml and assign them to navigation items and page content. See Role-based access control for the full setup.
Set up an authenticated account for Fern so Fern can authorize users on your behalf, and configure your OAuth application to return user API keys when Fern requests tokens. Contact support@buildwithfern.com to coordinate this setup.