https://www.mediawiki.org/wiki/API:Edit recommends that the token parameter should be the last parameter in the stream sent to the server, especially if the md5 is not used.
The code to produce the list of parameters is class Request in pywikibot/data/api.py.