All of the documentation that you link to looks right to me, *except* for the auto-generated example at https://www.mediawiki.org/w/api.php?action=help&modules=login. As you say, that example seems to imply that you'd call 'action=login' with a GET request and put everything in the URI; but in fact, that is not allowed.
> Also API:Main page - MediaWiki <https://www.mediawiki.org/wiki/API:Main_page> says that ”*tokens <https://www.mediawiki.org/w/api.php?action=help&modules=tokens>** is * *Deprecated.* Get tokens for data-modifying actions”. That statement is in the list of values of the 'action' parameter; so what it's saying is that 'action=tokens' is deprecated. It's *not* saying that 'action=query&meta=tokens' is deprecated; in fact, as explained at https://www.mediawiki.org/w/api.php?action=help&modules=tokens, 'action=tokens' is deprecated *in favor of* 'action=query&meta=tokens'. I've never used Ansible, but your request seems to be a mixture of what https://en.wikipedia.org/wiki/Help:Creating_a_bot#Logging_in calls "Request 1" and what it calls "Request 2". As explained at that page, you need to make two separate requests: "Request 1" is where you get a login token from 'action=query&meta=tokens', and "Request 2" is where you use that login token, plus the username and password, to actually log in. -Ran On Wed, Apr 14, 2021 at 12:04 AM Henrik Rasmussen <h...@adm.ku.dk> wrote: > My current version of mediawiki installation is 1.32.0. I am trying to use > Ansible to interface update Mediawiki. > > > > There seems to be some contradictions in the API documentation. > > > > · The Help:Creating a bot - Wikipedia > <https://en.wikipedia.org/wiki/Help:Creating_a_bot#Logging_in> says that > lgname, lgpassword and lgtoken should be used in a POST, > > · while the MediaWiki API help > <https://www.mediawiki.org/w/api.php?action=help&modules=login> says that > user id and password should be a part of the URI: > *api.php?action=login&lgname=user&lgpassword=password > <https://t-dokuwiki.it.ku.dk/dokuwiki/api.php?action=login&lgname=user&lgpassword=password>* > . > > · Also API:Main page - MediaWiki > <https://www.mediawiki.org/wiki/API:Main_page> says that ”*tokens > <https://www.mediawiki.org/w/api.php?action=help&modules=tokens>** is * > *Deprecated.* Get tokens for data-modifying actions”. > > > > From the ansible.builtin.uri – Interacts with webservices — Ansible > Documentation > <https://docs.ansible.com/ansible/latest/collections/ansible/builtin/uri_module.html#examples>, > the way to POST, is to insert > > > > body_format*:* form-urlencoded > > body*:* > > name*:* your_username > > password*:* your_password > > enter*:* Sign in > > > > which I think must be > > > > - name: Logging in to wiki.server > uri: > url: > https://wiki.server/wiki/api.php?action=query&meta=tokens&type=login&format=json > method: POST > force_basic_auth: yes > > body_format*:* form-urlencoded > > body*:* > > lgname*:* your_username > > lgpassword*:* your_password > > lgtoken*:* Sign in > > > > but this gives me > > > > "warnings": { > > "main": { > > "*": "Unrecognized parameters: lgname, lgtoken, > lgpassword." > > } > > > What is the correct documentation? > > > > Your sincerily > > > > *Henrik Rasmussen* > > System administrator > > > > > _______________________________________________ > Mediawiki-api mailing list > Mediawiki-api@lists.wikimedia.org > https://lists.wikimedia.org/mailman/listinfo/mediawiki-api >
_______________________________________________ Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api