How to solve this, I am using onlyoffice with react. While opening my word file(docx file) i get the error “The document security token is not correctly formed. Please contact your Document Server administrator.”

import React, { useState, useEffect } from “react”;
import { DocumentEditor } from “@onlyoffice/document-editor-react”;

const OnlyOffc = (props) => {
const [docUrl, setDocUrl] = useState(“”);
let token = sessionStorage.getItem(“jwt_token”);
let username = localStorage.getItem(“username”);
let deptRole = sessionStorage.getItem(“role”);
let sessionId = sessionStorage.getItem(“sessionId”);
console.log(props.url, token, “this”);
let correctUrl = props?.url?.replaceAll(“xxxyyyzzz”, “/”);

const onDocumentReady = () => {
console.log(“Document is loaded”);

const onLoadComponentError = function (errorCode, errorDescription) {
switch (errorCode) {
case -1: // Unknown error loading component

case -2: // Error load DocsAPI from http://documentserver/

case -3: // DocsAPI is not defined

useEffect(() => {
fetch(For_Getting_the_file_url, { //to get the file url
headers: {
“Content-Type”: “application/json”,
Authorization: "Bearer " + token,
username: username,
deptRole: deptRole,
sessionId: sessionId,
.then(async (res) => {
console.log(res, “res”);
let data = await res.blob();
// console.log(data);

let file = new File([data], “test.docx”);

setDocUrl(URL.createObjectURL(file)); // set object URL of file as docUrl
.catch((error) => {
}, [correctUrl, token, username, deptRole, sessionId]);

console.log(“docurl”, docUrl);

return (

{docUrl && (
documentServerUrl=“DOCKER_URL” //getting from docker
document: {
key: “SECRET_KEY”,
fileType: “docx”,
title: “farmer.docx”,
url: docUrl,
documentType: “word”,
type: “desktop”,
height: “800px”,
width: “100%”,

export default OnlyOffc;

“services”: {
“CoAuthoring”: {
“sql”: {
“token”: {
“enable”: {
“request”: {
“inbox”: true,
“outbox”: true,
“browser”: true
“inbox”: {
“header”: “Authorization”,
“inBody”: false
“outbox”: {
“header”: “Authorization”,
“inBody”: false
“secret”: {
“inbox”: {
“string”: “SECRET_KEY”
“outbox”: {
“string”: “SECRET_KEY”
“session”: {
“string”: “SECRET_KEY”
“rabbitmq”: {
“url”: “Some_URL”
“wopi”: {
“enable”: false,
“privateKey”: “SOMEVALUES”,
“privateKeyOld”: “SOMEVALUES”,
“publicKey”: “SOMEVALUES”,
“publicKeyOld”: “SOMEVALUES”,
“modulus”: “SOMEVALUES”,
“modulusOld”: “SOMEVALUES”,
“exponent”: 12333,
“exponentOld”: 11111
“queue”: {
“type”: “abc”
“storage”: {
“fs”: {
“secretString”: “MY_SECRET_KEY”



  • JWT_ENABLED=true
  • JWT_HEADER=Authorization
    how to resolve that error

Hello @Captain_roger
Please do not spam the same request in different topics. Other topics will be closed, let’s focus on this one.
Please reproduce the situation and collect Document server logs folder. It’s located here:
docker: /app/onlyoffice/DocumentServer/logs/documentserver/
deb\rpm: /var/log/onlyoffice/documentserver/
Windows: Program Files\ONLYOFFICE\DocumentServer\log

Additionally, please double-check that JWT secret and header match on the both sides (Document server and your storage\app).
One more thing, please point me to the installation guide that you used and clarify the Document server version.

nginx.error.log (23.5 KB)

@Alexandre is there any update regarding my issue.

@Alexandre i resolve the error “The document security token is not correctly formed. Please contact your Document Server administrator”, this is coming because the token i generated is not same as the config object but now i resolve this. Now i get the “Document Failed” error. Could you please help me to debug this.

Hello @Captain_roger
Well done. Please reproduce the issue and share fresh logs.
NB! Please share entire folder, not the nginx log only. We need to take a look at converter and docservice logs as well.

@Alexandre thanks for replying, now the “Download Failed” error is also resolved but one new error come. The file content is not their it show the some javascript error instead of file content

@Alexandre is there any update?

Hello @Captain_roger
Sorry for the late replies.
‘javaScript isn’t enabled in your browser’ - this is strange. Is the issue reproducible in different browsers? What is your browser version?
As for logs, please reproduce the situation again and check if there’re any error entries in docservice and converter logs (out.log file).
So far, it seems like the browser issue.

@Alexandre I also try in firefox and internet explorer but same things happen. File is open but intead of its content Javascript is not enable error is coming.
When i try with pdftron then file open correctly and its content also. But i don’t know what is the issue with onlyoffice. Even i clean my cache and cookies also as i go through serveral docs

@Alexandre, is there any update?

Hello @Captain_roger

Please share all logs of Document Server after reproducing the issue in a single archive for analysis.

In general, please make sure that you are providing a direct link to the file in document.url parameter when initializing editors. By direct I mean that it should directly download the file when pasting the link to the browser.

@Constantine I also try with that url also but still some JavaScript Error is coming.

Please check login page of your application in Incognito Mode of the browser. Maybe this page is projected into the document when opening document. Also try opening link to the document from Incognito too.

thanks for reply @Constantine , i checked in both Incognito mode and some other browser also but i get the same error my file open but there is written that javascript isn’t enable in your browser. How it is possible even though my whole application is build in JavaScript all is working fine but this getting the error

Did you check file URL that you are providing to Document Server as I asked here?

Can you share your initialization config for analysis?