1

Topic: mlmmadmin API token errors

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 1.0
- Deployed with iRedMail Easy or the downloadable installer?: neither, manual
- Linux/BSD distribution name and version: FreeBSD 11.3
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL 8.0.19
- Web server (Apache or Nginx): Nginx 1.16
- Manage mail accounts with iRedAdmin-Pro? Yes, IredAdmin-Pro 4.2
====
Both mlmmjadmin and iredadmin(-pro) need a token in order to function properly (and communicate with each other).
I am experiencing errors in the IredAdmin-Pro interface in one particular circumstance, and one only:
- when trying to edit existing users

The API token is configured in mlmmjadmin and iredadmin settings.py configuration files:
/opt/mlmmjadmin -> api_auth_tokens = '43a89b7aatokenhash'
/opt/www/iredadmin -> mlmmjadmin_api_auth_token = '43a89b7aatokenhash'

The formatting of the token is very particular. In the above example the application interface returns, when trying to edit existing mail users.

Error: InvalidHeader("Value for header {X-MLMMJADMIN-API-AUTH-TOKEN: ['43a89b7aatokenhash']} must be of type str or bytes, not <type 'list'>",)

When I change the format string to:
/opt/mlmmjadmin -> api_auth_tokens = ['43a89b7aatokenhash']
/opt/www/iredadmin -> mlmmjadmin_api_auth_token = ['43a89b7aatokenhash']

the same error appears

Error: InvalidHeader("Value for header {X-MLMMJADMIN-API-AUTH-TOKEN: ['43a89b7aatokenhash']} must be of type str or bytes, not <type 'list'>",)

Which is odd, because ['43a89b7aatokenhash'] is the prescribed format

When I change the format string to:
/opt/mlmmjadmin -> api_auth_tokens = ['43a89b7aatokenhash']
/opt/www/iredadmin -> mlmmjadmin_api_auth_token = '43a89b7aatokenhash'

The following error occurs:
Error: JSONDecodeError('Expecting value: line 1 column 1 (char 0)',)

When I change the format string to:
/opt/mlmmjadmin -> api_auth_tokens = '43a89b7aatokenhash'
/opt/www/iredadmin -> mlmmjadmin_api_auth_token = ['43a89b7aatokenhash']

The old error returns:
Error: InvalidHeader("Value for header {X-MLMMJADMIN-API-AUTH-TOKEN: ['43a89b7aatokenhash']} must be of type str or bytes, not <type 'list'>",)

In any case none of these variations gives me the desired result: the ability to edit mail user accounts

please advise.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: mlmmadmin API token errors

mlmmjadmin is the api server, it supports multiple api tokens used by different clients, so it’s a list in its config file:

 api_auth_tokens = ['43a89b7aatokenhash']

iRedAdmin-Pro is a mlmmjadmin api client, it used only one api token, so it’s a string:

 mlmmjadmin_api_auth_token = '43a89b7aatokenhash'

3

Re: mlmmadmin API token errors

ZhangHuangbin wrote:

mlmmjadmin is the api server, it supports multiple api tokens used by different clients, so it’s a list in its config file:

 api_auth_tokens = ['43a89b7aatokenhash']

iRedAdmin-Pro is a mlmmjadmin api client, it used only one api token, so it’s a string:

 mlmmjadmin_api_auth_token = '43a89b7aatokenhash'

Thx for the quick response and clear reply.
This still leaves me stuck with the following error response:
Error: JSONDecodeError('Expecting value: line 1 column 1 (char 0)',)

4

Re: mlmmadmin API token errors

- This is not expected, seems something wrong with configuration or data. I cannot figure it out with only this message.
- Any related error / log in /var/log/mlmmjadmin/mlmmjadmin.log? Or /var/log/messages? (Anyway, just try to get me some more related log for troubleshooting)

5

Re: mlmmadmin API token errors

Thx for working with me on this one.
Nothing in the mlmmj log. Mlmmj is in debug mode.

These messages in the iredadmin access log:
[16/May/2020:12:22:58 +0200] "GET /profile/user/general/peter@newbornmedia.com HTTP/1.1" 303 5 "https://mailadmin.coollective.nl/users/ … 9%27%2C%29" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
[16/May/2020:12:23:00 +0200] "GET /users/newbornmedia.com?msg=JSONDecodeError%28%27Expecting%20value%3A%20line%201%20column%201%20%28char%200%29%27%2C%29 HTTP/1.1" 200 5963 "https://mailadmin.coollective.nl/users/ … 9%27%2C%29" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"

This is basically what I see on my admin screen
Note the 303 and 200 response codes

Nothing related found in either system messages, mysql or nginx logs.

Both iredadmin and mlmj are configured on ports instead of socket files:
iredadmin uwsgi-2.7 6973  6  tcp4   10.20.0.1:7791        *:*
mlmmj     uwsgi-2.7  7113  6  tcp4   10.20.0.1:7790        *:*

6

Re: mlmmadmin API token errors

Any related log in /var/log/messages?

7

Re: mlmmadmin API token errors

ZhangHuangbin wrote:

Any related log in /var/log/messages?

nope

Is the error mlmmj API related or for instance database? I'm thinking I might have missed an upgrade on the database structure.

8

Re: mlmmadmin API token errors

- It's related to mlmmjadmin (restful api server).
- It's hard to troubleshoot with this short error message.
- Could you try to upgrade iRedMail to the latest iRedMail-1.2.1 and latest iRedAdmin-Pro first and try again?