nodeJS - checkJwt error: name = JsonWebTokenError message = jwt must be provided token = undefined

HI guys:

I’m working with the docker image `onlyoffice/documentserver:7.5
and Type of installation of the Document Server docker. Browser version: Chrome 108.0.5359.125.

I have a problem and trying to integrated with js code . I get error message:

image

I konws here to set JWT in js code, but I dont konw how to set.

access http://192.168.163.130:8080/example/?xxx is OK.

please help me.

docker run command:

docker run -i -t --name onlyoffice -d -p 8080:80 --restart=always \
    -e JWT_SECRET="cLAGd1BajRR6My93uqCdOPblEvZYTRpP" \
    onlyoffice/documentserver:7.5

/var/log/onlyoffice/documentserver/docservice/out.log:

[2024-02-29T09:07:00.933] [WARN] [localhost] [docId] [userId] nodeJS - Express server starting...
[2024-02-29T09:07:00.954] [WARN] [localhost] [docId] [userId] nodeJS - Failed to subscribe to plugin folder updates. When changing the list of plugins, you must restart the server. https://nodejs.org/docs/latest/api/fs.html#fs_availability
[2024-02-29T09:07:01.748] [WARN] [localhost] [docId] [userId] nodeJS - Express server listening on port 8000 in production-linux mode. Version: 7.5.1. Build: 23
[2024-02-29T09:07:08.884] [WARN] [localhost] [cLAGd1BajRR6My93uqCdOPblEvZYTRpP] [userId] nodeJS - checkJwt error: name = JsonWebTokenError message = jwt must be provided token = undefined

docker status:

[root@template Python_Example]# docker ps
CONTAINER ID   IMAGE                           COMMAND                   CREATED         STATUS         PORTS                                            NAMES
8946dbc8418e   onlyoffice/documentserver:7.5   "/app/ds/run-documen…"   5 minutes ago   Up 4 minutes   443/tcp, 0.0.0.0:8080->80/tcp, :::8080->80/tcp   onlyoffice

js code:

192.168.163.130:8080 is document Server on  vmware ip address.

<body style="height: 100%; margin: 0;">
    <div id="placeholder" style="height: 100%"></div>
    <script type="text/javascript" src="http://192.168.163.130:8080/web-apps/apps/api/documents/api.js"></script>

    <script type="text/javascript">

        window.docEditor = new DocsAPI.DocEditor("placeholder",
            {
                "document": {
                    "fileType": "docx",
                    "key": 'cLAGd1BajRR6My93uqCdOPblEvZYTRpP', ---> setup JWT with dokcer environment , but not working seem.
                    "title": "Example Document Title.docx",
                    "url": "http://192.168.163.130:8080/example/editor?fileName=new.docx"
                },
                "documentType": "word",
                "editorConfig": {
                    "callbackUrl": "http://192.168.163.130:8080/url-to-callback.ashx"
                },
                "height": "100%",
                "width": "100%"
            });

    </script>
</body>

You need to generate the token and then add it to the config object to be send to the docEditor. For example, using jsonwebtoken

let jwt = require('jsonwebtoken');
let config = {
                "document": {
                    "fileType": "docx",
                    "title": "Example Document Title.docx",
                    "url": "http://192.168.163.130:8080/example/editor?fileName=new.docx"
                },
                "documentType": "word",
                "editorConfig": {
                    "callbackUrl": "http://192.168.163.130:8080/url-to-callback.ashx"
                },
                "height": "100%",
                "width": "100%"
            });
let token = jwt.sign(config, secret);
config.token = token;

window.docEditor = new DocsAPI.DocEditor("placeholder", config);

I hope this helps,

If you don’t mind I will join to this thread too.
@str Thank you for your tips!
@myld, as independent integrator you need to implement JWT on the side of your storage on your own. We can provide a few samples on different programming languages for your reference: ONLYOFFICE Api Documentation - Language-specific examples
Please check them out.

As for your code sample:

 "document": {
                    "fileType": "docx",
                    "key": 'cLAGd1BajRR6My93uqCdOPblEvZYTRpP', ---> setup JWT with dokcer environment , but not working seem.
                    "title": "Example Document Title.docx",

This code is related to editor initialization config file. The ‘key’ parameter is the one of major parameters to provide simultaneous editing function: ONLYOFFICE Api Documentation - Config
This parameter isn’t related to JWT.
About the JWT in general: ONLYOFFICE Api Documentation - Security

Please feel free to contact us if you face any issues.