Auto-populate API keys

Make integrating with your API frictionless by adding your login flow to the API Explorer.

This feature is available on the Pro plan. Contact us to learn more.

Fern can integrate with your authentication flow, allowing users to login and have their API key automatically populated with the click of a button.

With this feature, you can create new users of your API directly from within your documentation.

Architecture

To enable this feature, you need to configure authentication so that Fern can securely retrieve API keys for your users. The process works as follows:

  1. When a user clicks the “Login” button in the API Explorer, they are redirected to your authentication page.
  2. After successful authentication, your system must set a cookie called fern_token in the user’s browser.
  3. This token should be a JWT that contains the user’s API key, encrypted with a secret key that we provide.

The JWT should have a structure similar to:

1{
2 "fern": {
3 "playground": {
4 "initial_state": {
5 "auth": {
6 "bearer_token": "Bearer eyJhbGciOiJIUzI1c"
7 }
8 }
9 }
10 }
11}