问题
I'm having problems authenticating with MediaWiki API in MediaWiki 1.28.
The API: https://www.mediawiki.org/wiki/API:Main_page
My exact attempt: https://github.com/tomasbjerre/git-changelog-lib/tree/feature/medawiki
How I'm doing it:
Authenticating to http://localhost:8889/w
Posting to: http://localhost:8889/w/api.php?action=query&meta=tokens&format=json&type=login
Got cookie: mediawiki_session=pnbmq5t2cq8gsnv4cm74lb6f3aa5vbeb; path=/; HttpOnly
Response: {"batchcomplete":"","query":{"tokens":{"logintoken":"bc18a93aedd4993634ddb8e28e6cd60259993ca3+\\"}}}
Using logintoken: bc18a93aedd4993634ddb8e28e6cd60259993ca3+\
Posting to: http://localhost:8889/w/api.php?action=login&format=json
Using cookie: mediawiki_session=pnbmq5t2cq8gsnv4cm74lb6f3aa5vbeb; path=/; HttpOnly
Post content: lgname=User%40botuser&lgpassword=*&lgtoken=bc18a93aedd4993634ddb8e28e6cd60259993ca3%2B%5C
Response: {"login":{"result":"Failed","reason":"The supplied credentials could not be authenticated."}}
I am using this compose to fiddle with MediaWiki 1.28: https://github.com/pastakhov/compose-mediawiki-ubuntu
I have created a bot-user that I am using to authenticate.
When using maintenance script eval.php like this:
root@9b3370557c92:/# cd /var/www/html/w/maintenance
root@9b3370557c92:/var/www/html/w/maintenance# php eval.php
And having a bot like this:
I get responses like:
> echo BotPassword::login( "User@newbot", "odqp6am3aerd6pa4gikm17d87a4r26dh", RequestContext::getMain()->getRequest() )->getMessage()->getKey();
internalerror_info
And if I dont prefix with User@ (ignoring what Mediawiki bot creation page suggests)
> echo BotPassword::login( "newbot", "odqp6am3aerd6pa4gikm17d87a4r26dh", RequestContext::getMain()->getRequest() )->getMessage()->getKey();
botpasswords-invalid-name
The documentation here is a mess. I would suggest rewriting it exclusively for 1.28 and keep the current page for legacy users.
回答1:
lgname
should be botuser
. (And if you aren't yet, you should be using a bot password.)
来源:https://stackoverflow.com/questions/45779754/cannot-authenticate-with-mediawiki-1-28-api