-
Notifications
You must be signed in to change notification settings - Fork 43
Admin Rest API
It is important that you enable the "admin" service in the "gateway" property of your tree-gateway.json file. If you do not enable it, no configuration can be done through this gateway instance.
The following configuration enables the admin service to listen, via https, the port 8001 and expose the API docs on path https://localhost:8001/api-docs:
{
"admin": {
"protocol": {
"https": {
"listenPort": 8001,
"privateKey": "./server.key",
"certificate": "./server.crt"
}
},
"userService": {
"jwtSecret": "secret"
},
"apiDocs": {
"path": "api-docs",
"host": "localhost"
}
}
}Accessing this URL https://localhost:8001/api-docs, you can see the swagger-ui interface, that allows you to explore and interact with the API.

You can also access the API swagger file through:
http://localhost:8001/api-docs/json
or
http://localhost:8001/api-docs/yaml
You need to provide an access token to all methods on the Admin API. To obtain this token, you must authenticate with the user you created in the previous step, by calling the endpoint:
http://localhost:8001/users/authentication
To do this through this swagger-ui, just follow the next steps.
Call /users/authenticate endpoint.

Use the user you created with userAdmin tool. The service will return a JWT token. Copy it.
Now you can authenticate through the swagger-ui interface, clicking in the red bang icon that appears on every api entrypoint to indicate you need authetication. Once you click it, a dialog will be opened to you enter your credentials. Just enter JWT <your token> and authenticate.

And the red bang comes blue. You are authenticated and can call any API method.
