Authentication
To initiate REST API requests, you must first log in to FortiPortal and acquire an API key.
The authorization key must be included in all subsequent API requests in the Authorization header. The key expires in one hour.
To acquire an API key in the GUI:
-
Log in to FortiPortal as an administrator.
-
In the header, click on the cog icon.
-
Click on API Key.
-
In the New API Key dialog, click Regenerate, then copy the API token .
Include the key in the API requests in this manner:
"-H "Authorization: Token <API_key>"
|
|
Acquiring a new key does not expire any other generated keys. |
To acquire a token in the API:
-
Log in and get a CSRF token.
Send a POST request to this url:
https://<ipaddress>/fpc/login/Parameters (JSON structure in the payload):
- username: a valid admin user name
- password: password for the above name
If the login is successful, the cookie will contain the CSRF token in the
csrftokenfield. -
Retrieve the authorization token.
Send a POST request to this url:
https://<ipaddress>/fpc/api/auth/login/Include the CSRF token from the previous step in the
X-CSRFTokenheader.The JSON response contains the authorization token in the
tokenfield.