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.

How it works

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 encrypted with a secret key that we provide. The JWT should contain the user’s API key.

The JWT should have a structure similar to:

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

Setting up auto-populated API keys

  • Reach out to Fern to get your secret key
  • Send Fern the URL of your authentication page (this is where users will be redirected to after clicking the “Login” button in the API Explorer)
  • Add logic to your service to set the fern_token cookie when a user logs in
For an example of how to set up the fern_token cookie, see our demo implementation here.