Closed riturajtiwari closed 2 weeks ago
@askonev Would love to get your thoughts on this issue.
Checking to see if this bug is on your radar
@riturajtiwari greetings. To generate the jwt token correctly, use the configuration in the json specification.
Document Server Configuration
JWT=true
JWT_SECRET=secret
JWT_HEADER=Authorization
Correct configuration based on your example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>OnlyOffice Document Editor</title>
<script type="text/javascript" src="http://192.168.4.138/web-apps/apps/api/documents/api.js"></script>
</head>
<body>
<div style="width: 600px; height: 600px;">
<div id="placeholder"></div>
</div>
<script>
var config = {
"document": {
"fileType": "docx",
"key": "Khirz6zTPdfd7",
"title": "Example Document Title.docx",
"url": "http://192.168.4.138:9090/files/empty.docx"
},
"documentType": "word",
"editorConfig": {
"callbackUrl": "https://example.com/url-to-callback.ashx",
"user": {
"id": "user123",
"name": "John Doe"
}
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb2N1bWVudCI6eyJmaWxlVHlwZSI6ImRvY3giLCJrZXkiOiJLaGlyejZ6VFBkZmQ3IiwidGl0bGUiOiJFeGFtcGxlIERvY3VtZW50IFRpdGxlLmRvY3giLCJ1cmwiOiJodHRwOi8vMTkyLjE2OC40LjEzODo5MDkwL2ZpbGVzL2VtcHR5LmRvY3gifSwiZG9jdW1lbnRUeXBlIjoid29yZCIsImVkaXRvckNvbmZpZyI6eyJjYWxsYmFja1VybCI6Imh0dHBzOi8vZXhhbXBsZS5jb20vdXJsLXRvLWNhbGxiYWNrLmFzaHgiLCJ1c2VyIjp7ImlkIjoidXNlcjEyMyIsIm5hbWUiOiJKb2huIERvZSJ9fSwiaGVpZ2h0IjoiMTAwJSIsIndpZHRoIjoiMTAwJSIsInR5cGUiOiJkZXNrdG9wIn0.m1CcF1lHFzYBK8eN5evFrlKdbrXTA_XabIrQXXk_Dv8"
};
var docEditor = new DocsAPI.DocEditor("placeholder", config);
</script>
</body>
</html>
I close this issue. Feel free to comment or reopen it if you got further questions.
This issue is unique.
Operating System of DocumentServer
Docker
Version information
onlyoffice/documentserver:latest
Expected Behavior
When the JWT token is supplied correctly, the server should render editor app without error
Actual Behavior
Server shows error
checkJwt error: name = JsonWebTokenError message = jwt must be provided token = undefined
Reproduction Steps
checkJwt error: name = JsonWebTokenError message = jwt must be provided token = undefined
Additional information
I followed the steps to create a minimal application for embedding the document editor widget. My setup is as follows:
onlyoffice/documentserver:latest
on Macbook Pro. Host port 9000 --> 80 on containereditor.html
The editor page template code is very simple:
When the template is rendered, all placeholders are correctly populated:
The
token
is calculated based on JWT secret obtained from the container. My Python code for generating the token to inject into the template is:The generated token validated correctly on JWT:
I'm thinking passing the token to the
iframe
rendered in my<div id="placeholder">
does not work when DocumentServer and my app are on different hosts (in this case, different ports).