Apidog allows you to protect your published API documentation with custom authentication. This guide walks you through configuring a custom login page that integrates with your existing authentication system using JWT (JSON Web Token).
Go to the visibility settings of the documentation site, select Custom Login Page, and fill in the following two fields:
JWT Secret: Used to verify the signature of the token. It must be the same as the secret your backend uses when issuing JWTs. You need to generate this secret yourself.
Login URL: When users access the online documentation site, they will be redirected to this URL. You must host a login page at this address and implement authentication and token generation on your backend.
This login page is not provided by Apidog — you need to build and host your own.
JWT (JSON Web Token) is an open standard for user authentication. Your login system should follow the flow below:
1.
A user visits the online documentation site published by Apidog (e.g., https://xxxxx.apidog.io);
2.
The system automatically redirects them to your configured login page (e.g., http://localhost:3000);
3.
The user enters their credentials and submits the form;
4.
Your backend verifies the user credentials;
5.
Upon successful authentication, your backend generates a JWT signed using your configured secret (e.g., pJRdFC3amihQdWbHvUXNZG9WzYdEGHao);
6.
Then, redirect the user back to the documentation site (e.g., https://xxxxx.apidog.io) and include the token as a query parameter named auth_token as shown below.
7.
Apidog will automatically validate the token. If successful, the user can access the documentation content.
The login flow is illustrated in the diagram below:
After successful authentication via your custom login page, the user's access session lasts for 30 days. During this period, users can access the documentation without re-authenticating. The session is stored as a browser cookie and expires automatically after 30 days.
Note
The session duration is currently fixed at 30 days and cannot be configured.
There are no restrictions. As long as your backend can handle POST login requests and return a URL containing auth_token, it will work. Node.js, PHP, Python, Go, etc., are all supported.