chore(docs): mention in the documentation about Bearer tokens

This commit is contained in:
Elian Doran 2025-04-15 17:56:18 +03:00
parent 46cbbec53a
commit bbc8536068
No known key found for this signature in database
5 changed files with 52 additions and 36 deletions

View File

@ -9636,6 +9636,13 @@
"isInheritable": false, "isInheritable": false,
"position": 10 "position": 10
}, },
{
"type": "relation",
"name": "internalLink",
"value": "habiZ3HU8Kw8",
"isInheritable": false,
"position": 20
},
{ {
"type": "relation", "type": "relation",
"name": "internalLink", "name": "internalLink",
@ -9649,13 +9656,6 @@
"value": "default-note-title", "value": "default-note-title",
"isInheritable": false, "isInheritable": false,
"position": 30 "position": 30
},
{
"type": "relation",
"name": "internalLink",
"value": "habiZ3HU8Kw8",
"isInheritable": false,
"position": 20
} }
], ],
"format": "markdown", "format": "markdown",
@ -10014,6 +10014,13 @@
"isInheritable": false, "isInheritable": false,
"position": 40 "position": 40
}, },
{
"type": "relation",
"name": "internalLink",
"value": "habiZ3HU8Kw8",
"isInheritable": false,
"position": 50
},
{ {
"type": "relation", "type": "relation",
"name": "internalLink", "name": "internalLink",
@ -10027,13 +10034,6 @@
"value": "bx bx-list-plus", "value": "bx bx-list-plus",
"isInheritable": false, "isInheritable": false,
"position": 10 "position": 10
},
{
"type": "relation",
"name": "internalLink",
"value": "habiZ3HU8Kw8",
"isInheritable": false,
"position": 50
} }
], ],
"format": "markdown", "format": "markdown",
@ -11066,32 +11066,32 @@
"mime": "text/markdown", "mime": "text/markdown",
"attributes": [ "attributes": [
{ {
"type": "label", "type": "relation",
"name": "shareAlias", "name": "internalLink",
"value": "script-api", "value": "CdNpE2pqjmI6",
"isInheritable": false, "isInheritable": false,
"position": 10 "position": 10
}, },
{ {
"type": "relation", "type": "relation",
"name": "internalLink", "name": "internalLink",
"value": "CdNpE2pqjmI6", "value": "Q2z6av6JZVWm",
"isInheritable": false, "isInheritable": false,
"position": 20 "position": 20
}, },
{ {
"type": "relation", "type": "relation",
"name": "internalLink", "name": "internalLink",
"value": "Q2z6av6JZVWm", "value": "MEtfsqa5VwNi",
"isInheritable": false, "isInheritable": false,
"position": 30 "position": 30
}, },
{ {
"type": "relation", "type": "label",
"name": "internalLink", "name": "shareAlias",
"value": "MEtfsqa5VwNi", "value": "script-api",
"isInheritable": false, "isInheritable": false,
"position": 40 "position": 10
} }
], ],
"format": "markdown", "format": "markdown",

View File

@ -9,16 +9,26 @@ As an alternative to calling the API directly, there are client libraries to sim
* [trilium-py](https://github.com/Nriver/trilium-py), you can use Python to communicate with Trilium. * [trilium-py](https://github.com/Nriver/trilium-py), you can use Python to communicate with Trilium.
## Obtaining a token
All operations with the REST API have to be authenticated using a token. You can get this token either from Options -> ETAPI or programmatically using the `/auth/login` REST call (see the [spec](https://github.com/TriliumNext/Notes/blob/master/src/etapi/etapi.openapi.yaml)).
## Authentication ## Authentication
All operations have to be authenticated using a token. You can get this token either from Options -> ETAPI or programmatically using the `/auth/login` REST call (see the [spec](https://github.com/TriliumNext/Notes/blob/master/src/etapi/etapi.openapi.yaml)): ### Via the `Authorization` header
``` ```
GET https://myserver.com/etapi/app-info GET https://myserver.com/etapi/app-info
Authorization: ETAPITOKEN Authorization: ETAPITOKEN
``` ```
Alternatively, since 0.56 you can also use basic auth format: where `ETAPITOKEN` is the token obtained in the previous step.
For compatibility with various tools, it's also possible to specify the value of the `Authorization` header in the format `Bearer ETAPITOKEN` (since 0.93.0).
### Basic authentication
Since v0.56 you can also use basic auth format:
``` ```
GET https://myserver.com/etapi/app-info GET https://myserver.com/etapi/app-info

View File

@ -8,12 +8,19 @@
<li><a href="https://github.com/Nriver/trilium-py">trilium-py</a>, you can <li><a href="https://github.com/Nriver/trilium-py">trilium-py</a>, you can
use Python to communicate with Trilium.</li> use Python to communicate with Trilium.</li>
</ul> </ul>
<h2>Obtaining a token</h2>
<p>All operations with the REST API have to be authenticated using a token.
You can get this token either from Options -&gt; ETAPI or programmatically
using the <code>/auth/login</code> REST call (see the <a href="https://github.com/TriliumNext/Notes/blob/master/src/etapi/etapi.openapi.yaml">spec</a>).</p>
<h2>Authentication</h2> <h2>Authentication</h2>
<p>All operations have to be authenticated using a token. You can get this <h3>Via the <code>Authorization</code> header</h3><pre><code class="language-text-x-trilium-auto">GET https://myserver.com/etapi/app-info
token either from Options -&gt; ETAPI or programmatically using the <code>/auth/login</code> REST
call (see the <a href="https://github.com/TriliumNext/Notes/blob/master/src/etapi/etapi.openapi.yaml">spec</a>):</p><pre><code class="language-text-x-trilium-auto">GET https://myserver.com/etapi/app-info
Authorization: ETAPITOKEN</code></pre> Authorization: ETAPITOKEN</code></pre>
<p>Alternatively, since 0.56 you can also use basic auth format:</p><pre><code class="language-text-x-trilium-auto">GET https://myserver.com/etapi/app-info <p>where <code>ETAPITOKEN</code> is the token obtained in the previous step.</p>
<p>For compatibility with various tools, it's also possible to specify the
value of the <code>Authorization</code> header in the format <code>Bearer ETAPITOKEN</code> (since
0.93.0).</p>
<h3>Basic authentication</h3>
<p>Since v0.56 you can also use basic auth format:</p><pre><code class="language-text-x-trilium-auto">GET https://myserver.com/etapi/app-info
Authorization: Basic BATOKEN</code></pre> Authorization: Basic BATOKEN</code></pre>
<ul> <ul>
<li>Where <code>BATOKEN = BASE64(username + ':' + password)</code> - this is <li>Where <code>BATOKEN = BASE64(username + ':' + password)</code> - this is

View File

@ -36,8 +36,8 @@
<h3>Running the Docker Container</h3> <h3>Running the Docker Container</h3>
<h4>Local Access Only</h4> <h4>Local Access Only</h4>
<p>Run the container to make it accessible only from the localhost. This <p>Run the container to make it accessible only from the localhost. This
setup is suitable for testing or when using a prox ay server like Nginx setup is suitable for testing or when using a proxy server like Nginx or
or Apache.</p><pre><code class="language-text-x-trilium-auto">sudo docker run -t -i -p 127.0.0.1:8080:8080 -v ~/trilium-data:/home/node/trilium-data triliumnext/notes:[VERSION]</code></pre> Apache.</p><pre><code class="language-text-x-trilium-auto">sudo docker run -t -i -p 127.0.0.1:8080:8080 -v ~/trilium-data:/home/node/trilium-data triliumnext/notes:[VERSION]</code></pre>
<ol> <ol>
<li>Verify the container is running using <code>docker ps</code>.</li> <li>Verify the container is running using <code>docker ps</code>.</li>
<li>Access Trilium via a web browser at <code>127.0.0.1:8080</code>.</li> <li>Access Trilium via a web browser at <code>127.0.0.1:8080</code>.</li>

View File

@ -1,11 +1,10 @@
<p>For <a href="#root/pOsGYCXsbNQG/_help_CdNpE2pqjmI6">script code notes</a>, <p>For <a href="#root/_help_CdNpE2pqjmI6">script code notes</a>, Trilium offers
Trilium offers an API that gives them access to various features of the an API that gives them access to various features of the application.</p>
application.</p>
<p>There are two APIs:</p> <p>There are two APIs:</p>
<ul> <ul>
<li>One for the front-end scripts:&nbsp;<a class="reference-link" href="#root/pOsGYCXsbNQG/CdNpE2pqjmI6/GLks18SNjxmC/_help_Q2z6av6JZVWm">Frontend API</a> <li>One for the front-end scripts:&nbsp;<a class="reference-link" href="#root/_help_Q2z6av6JZVWm">Frontend API</a>
</li> </li>
<li>One for the back-end scripts:&nbsp;<a class="reference-link" href="#root/pOsGYCXsbNQG/CdNpE2pqjmI6/GLks18SNjxmC/_help_MEtfsqa5VwNi">Backend API</a> <li>One for the back-end scripts:&nbsp;<a class="reference-link" href="#root/_help_MEtfsqa5VwNi">Backend API</a>
</li> </li>
</ul> </ul>
<p>In both cases, the API resides in a global variable, <code>api</code>, <p>In both cases, the API resides in a global variable, <code>api</code>,