In the past I have automated the configuration of the WP-Matomo (WP-Piwik) plugin by getting the
token_auth string for the user using a MySQL query and then setting the required variables using the WordPress CLI (see the Ansible tasks here).
However with Matomo 4.x the
token_auth string is encrypted in the database so this won’t work.
Last year when asked about this on GitHub:
The answer given was to use the API:
You can find more info about APIs here: https://developer.matomo.org/api-reference/reporting-api
UsersManager.getTokenAuthmethod to get token.
However that method is not in the list of UsersManaged methods, is there an undocumented method that can be used or is some PHP now needed to access the
token_auth for a user?