Odoo connector JWT issues, unable to view/edit attachments

Hi Everyone. We’re running the OnlyOffice 15.0 module on Odoo 15 CE. Everything’s setup as instructed on both sides. Docserver is running perfectly with other apps such as Nextcloud. When clicking on a PDF or DOCX attachment in Odoo, we’re experiencing the “Download failed” popup in the browser with the following logs:

OnlyOffice Converter – out.log:

2023-12-10T08:20:49.711] [ERROR] [localhost] [8864c4582ab35193902b2ccfe343f3309d0d99233000] [9] nodeJS - error downloadFile:url=https://odoo-server/onlyoffice/file/content/8864?oo_security_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6OX0.77HMdvpnCI3NdumWP8Tf-1VB2nbRUbD33eDJIlB3MSU;attempt=1;code:undefined;connect:undefined Error: Error response: statusCode:500; headers:{“server”:“nginx/1.18.0”,“date”:“Sun, 10 Dec 2023 00:20:49 GMT”,“content-type”:“text/html;charset=utf-8”,“content-length”:“1810”,“connection”:“keep-alive”,“set-cookie”:[“frontend_lang=en_GB; Path=/”,“session_id=7474c96dd4fe46d662a4cbfc67703a675a95c143; Expires=Sat, 09-Mar-2024 00:20:49 GMT; Max-Age=7776000; HttpOnly; Path=/”]};
at Request.fResponse (/snapshot/server/build/server/Common/sources/utils.js)
at Request.emit (events.js:400:28)
at Request.onRequestResponse (/snapshot/server/build/server/Common/node_modules/request/request.js:1059:10)
at ClientRequest.emit (events.js:400:28)
at HTTPParser.parserOnIncomingClient (_http_client.js:647:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:127:17)
at TLSSocket.socketOnData (_http_client.js:515:22)
at TLSSocket.emit (events.js:400:28)
at addChunk (internal/streams/readable.js:293:12)
at readableAddChunk (internal/streams/readable.js:267:9)
at TLSSocket.Readable.push (internal/streams/readable.js:206:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23)

When directly accessing the URL above: https://odoo-server/onlyoffice/file/content/8864?oo_security_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6OX0.77HMdvpnCI3NdumWP8Tf-1VB2nbRUbD33eDJIlB3MSU

The browser will show a 500 error with the following output:

Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py”, line 237, in _dispatch
result = request.dispatch()
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 815, in dispatch
r = self._call_function(**self.params)
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 368, in _call_function
return checked_call(self.db, *args, **kwargs)
File “/usr/lib/python3/dist-packages/odoo/service/model.py”, line 94, in wrapper
return f(dbname, *args, **kwargs)
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 357, in checked_call
result = self.endpoint(*a, **kw)
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 921, in call
return self.method(*args, **kw)
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 546, in response_wrap
response = f(*args, **kw)
File “/usr/lib/python3/dist-packages/odoo/addons/onlyoffice_odoo/controllers/controllers.py”, line 35, in onlyoffice_get_file_content
raise Exception(“expected JWT”)
Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py”, line 237, in _dispatch
result = request.dispatch()
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 815, in dispatch
r = self._call_function(**self.params)
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 368, in _call_function
return checked_call(self.db, *args, **kwargs)
File “/usr/lib/python3/dist-packages/odoo/service/model.py”, line 94, in wrapper
return f(dbname, *args, **kwargs)
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 357, in checked_call
result = self.endpoint(*a, **kw)
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 921, in call
return self.method(*args, **kw)
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 546, in response_wrap
response = f(*args, **kw)
File “/usr/lib/python3/dist-packages/odoo/addons/onlyoffice_odoo/controllers/controllers.py”, line 35, in onlyoffice_get_file_content
raise Exception(“expected JWT”)
Exception: expected JWT

We tried disabling tokens in the local.json configuration and removed the JWT secret from the Odoo configuration. Accessing the URL above from a browser logged into Odoo results in a download (without the OnlyOffice interface). However, from a different machine, it displays a 500 error with the following in the Odoo log:

2023-12-10 03:05:42,669 1507395 ERROR odoo odoo.addons.http_routing.models.ir_http: 500 Internal Server Error:

Traceback (most recent call last):
File “/usr/lib/python3.9/base64.py”, line 43, in _bytes_from_decode_data
return memoryview(s).tobytes()
TypeError: memoryview: a bytes-like object is required, not ‘NoneType’

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py”, line 237, in _dispatch
result = request.dispatch()
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 815, in dispatch
r = self._call_function(**self.params)
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 368, in _call_function
return checked_call(self.db, *args, **kwargs)
File “/usr/lib/python3/dist-packages/odoo/service/model.py”, line 94, in wrapper
return f(dbname, *args, **kwargs)
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 357, in checked_call
result = self.endpoint(*a, **kw)
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 921, in call
return self.method(*args, **kw)
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 546, in response_wrap
response = f(*args, **kw)
File “/usr/lib/python3/dist-packages/odoo/addons/onlyoffice_odoo/controllers/controllers.py”, line 41, in onlyoffice_get_file_content
content_base64 = base64.b64decode(content)
File “/usr/lib/python3.9/base64.py”, line 80, in b64decode
s = _bytes_from_decode_data(s)
File “/usr/lib/python3.9/base64.py”, line 45, in _bytes_from_decode_data
raise TypeError("argument should be a bytes-like object or ASCII "
Exception

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_http.py”, line 237, in _dispatch
result = request.dispatch()
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 815, in dispatch
r = self._call_function(**self.params)
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 368, in _call_function
return checked_call(self.db, *args, **kwargs)
File “/usr/lib/python3/dist-packages/odoo/service/model.py”, line 94, in wrapper
return f(dbname, *args, **kwargs)
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 357, in checked_call
result = self.endpoint(*a, **kw)
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 921, in call
return self.method(*args, **kw)
File “/usr/lib/python3/dist-packages/odoo/http.py”, line 546, in response_wrap
response = f(*args, **kw)
File “/usr/lib/python3/dist-packages/odoo/addons/onlyoffice_odoo/controllers/controllers.py”, line 41, in onlyoffice_get_file_content
content_base64 = base64.b64decode(content)
File “/usr/lib/python3.9/base64.py”, line 80, in b64decode
s = _bytes_from_decode_data(s)
File “/usr/lib/python3.9/base64.py”, line 45, in _bytes_from_decode_data
raise TypeError("argument should be a bytes-like object or ASCII "
TypeError: argument should be a bytes-like object or ASCII string, not ‘NoneType’

Odoo & OnlyOffice are running on the same machine, both behind a Nginx proxy. They are being accessed from a remote network. We tried running a bare minimum Nginx configuration with the same results.

Any ideas? Happy to assist with the debugging process, thanks!

Hi @fmcsecurity

  1. Is the problem occurring only when opening attachments in Odoo?
  2. Creating a document and subsequently reopening it works correctly?

Thanks for the reply Nikolas, turns out it was an Nginx permissions problem. Specifically, 403 when accessing https://docserver/cache/files/data/*

Tracking it down was a bit challenging (lots of moving parts!), had to peel the layers of the onion. This wasn’t immediately obvious from the Nginx/Odoo/OnlyOffice logfiles. The 500 error threw me off, was originally going down a different rabbit hole.

Now everything’s working flawlessly. Pairing OnlyOffice with Odoo is an absolute dream :smiling_face_with_three_hearts:

If anyone’s having similar problems, check the includes/ds-* configurations, they might need adjusting (even if everything’s working fine with Nextcloud or other connectors).

2 Likes

@fmcsecurity , I’m really glad that you’ve resolved the issue, and most importantly, shared the solution with other users. :+1:

Thank you for taking the time to post your solution on the forum. :hugs:

Hi,

do you have any further informations about the adjustments you have done to includes/ds-* configuration?

Thank you very much
best regards,