Invalid Security Token Document Editor

Hello everyone,

I am using Onlyoffice’s latest document server (Developer Edition) version 7.4.1 on Windows 11 (without using docker).
When I try to open Word document using Document Editor @onlyoffice/document-editor-react I am getting this error “The document security token is not correctly formed. Please contact your Document Server administrator”.

I created the following token using the secret key from local.json and config as payload but it is not working:

“token=“eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb2N1bWVudFR5cGUiOiJ3b3JkIiwiaGVpZ2h0IjoiOTYlIiwid2lkdGgiOiIxMDAlIiwiZG9jdW1lbnQiOnsiZmlsZVR5cGUiOiJkb2N4Iiwia2V5IjoiZ2kzNGZvdnhmNnQiLCJ0aXRsZSI6IkFydGljbGVzIG9mIEFzc29jaWF0aW9uLmRvY3giLCJ1cmwiOiIiLCJwZXJtaXNzaW9ucyI6e319LCJlZGl0b3JDb25maWciOnsiY3VzdG9taXphdGlvbiI6eyJsb2dvIjp7ImltYWdlIjoiaHR0cDovL2xvY2FsaG9zdDozMDAwL2Fzc2V0cy9pbWFnZXMvdHJhbnNwYXJlbnQtcG5nLnBuZyJ9LCJ1aVRoZW1lIjoidGhlbWUtY2xhc3NpYy1saWdodCJ9fSwiaWF0IjoxNjk1ODIzMjE2LCJleHAiOjE2OTU4MjY4MTZ9.HW1IcsmeJXnutuzSILeimZa4j18YKjC21-c85L6CPaE””

I am able to open documents if I disable the token value from local.json but I want to use token because it is a must requirement if I want to open local files using the document editor;
https://api.onlyoffice.com/editors/security

Also, how can I restart the document server on Windows without using docker after modifying the config e.g local.json file. I have to restart my machine each time to reflect the changes.

Here you can see the error and the config files

Document Server version: exe
OS: Windows 11
Browser version: Chrome Version 117.0.5938.92

Hello @hereisfahad

Open Windows Services and restart all Document Server services there.

I’m not sure how you are providing token right now, but take a look at the documentation on React component about config:

config - Generic configuration object for opening a file with token.

Considering that, you have to provide token inside the initialization config to make it work.

If you still experiencing difficulties with proper JWT token usage, you can also install test example to check how it is implemented there:
https://api.onlyoffice.com/editors/demopreview

By the way, if you have active license, you can also contact us via Zendesk to get prompt replies.

Thank you for your reply. I am generating a token with this payload and using the secret from the local.json config file.

{
      documentType,
      height,
      width,
      document: {
        fileType,
        key,
        title,
        url,
        permissions,
      },
      editorConfig: {
        callbackUrl,
        user: {
          name,
          id,
        },
        customization: {
          customer: {},
          anonymous: {
            request: false,
          },
          autosave: false,
          logo: {
            image: `logo.png`,
          },
          uiTheme: "theme-classic-light",
          feedback: false,
          help: false,
        },
      },
    }

Now, the error is not occurring, but I am getting this ‘Download Failed’ error.image

I am passing the token in the config prop just like mentioned in the documentation.

<DocumentEditor
      id={id}
      documentServerUrl={process.env.REACT_APP_ONLY_OFFICE_DOCUMENT_SERVER_URL}
      config={{
        ...config,
        token
      }}
    />

Please find logs of Document Server, archive them to share with us for analysis. For Windows installation logs are located in C:\Program Files\ONLYOFFICE\DocumentServer\Log\.