title: Cannot authenticate with MediaWiki 1.28 API
body: <p>I'm having problems authenticating with MediaWiki API in MediaWiki 1.28.</p>
  
  <p>The API: <a href="https://www.mediawiki.org/wiki/API:Main_page" rel="nofollow noreferrer">https://www.mediawiki.org/wiki/API:Main_page</a></p>
  
  <p>My exact attempt: <a href="https://github.com/tomasbjerre/git-changelog-lib/tree/feature/medawiki" rel="nofollow noreferrer">https://github.com/tomasbjerre/git-changelog-lib/tree/feature/medawiki</a></p>
  
  <p>How I'm doing it:</p>
  
  <pre><code>Authenticating to http://localhost:8889/w
  Posting to: http://localhost:8889/w/api.php?action=query&amp;meta=tokens&amp;format=json&amp;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&amp;format=json
  Using cookie: mediawiki_session=pnbmq5t2cq8gsnv4cm74lb6f3aa5vbeb; path=/; HttpOnly
  Post content: lgname=User%40botuser&amp;lgpassword=*&amp;lgtoken=bc18a93aedd4993634ddb8e28e6cd60259993ca3%2B%5C
  Response: {"login":{"result":"Failed","reason":"The supplied credentials could not be authenticated."}}
  </code></pre>
  
  <p>I am using this compose to fiddle with MediaWiki 1.28:
  <a href="https://github.com/pastakhov/compose-mediawiki-ubuntu" rel="nofollow noreferrer">https://github.com/pastakhov/compose-mediawiki-ubuntu</a></p>
  
  <p>I have created a bot-user that I am using to authenticate.</p>
  
  <p>When using maintenance script eval.php like this:</p>
  
  <pre><code>root@9b3370557c92:/# cd /var/www/html/w/maintenance 
  root@9b3370557c92:/var/www/html/w/maintenance# php eval.php 
  </code></pre>
  
  <p>And having a bot like this:</p>
  
  <p><a href="https://i.stack.imgur.com/nZsRM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nZsRM.png" alt="enter image description here"></a></p>
  
  <p>I get responses like:</p>
  
  <pre><code>&gt; echo BotPassword::login( "User@newbot", "odqp6am3aerd6pa4gikm17d87a4r26dh", RequestContext::getMain()-&gt;getRequest() )-&gt;getMessage()-&gt;getKey();
  internalerror_info
  </code></pre>
  
  <p>And if I dont prefix with User@ (ignoring what Mediawiki bot creation page suggests)</p>
  
  <pre><code>&gt; echo BotPassword::login( "newbot", "odqp6am3aerd6pa4gikm17d87a4r26dh", RequestContext::getMain()-&gt;getRequest() )-&gt;getMessage()-&gt;getKey();     
  botpasswords-invalid-name
  </code></pre>
  
  <p><a href="https://www.mediawiki.org/wiki/API:Login" rel="nofollow noreferrer">The documentation</a> here is a mess. I would suggest rewriting it exclusively for 1.28 and keep the current page for legacy users.</p>