Cannot authenticate with MediaWiki 1.28 API

无人久伴 提交于 2019-12-13 03:48:01

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!