Cannot Use With Private Wikis
jtmullen opened this issue · 8 comments
I was trying to use this out on a private MediaWiki wiki (one that requires a log in for any actions) and this fails with the following error:
::error::readapidenied: You need read permission to use this module.
I tried the same simple code, to login and read a page, on Wikipedia and it worked as expected so my code seems all good.
This seems similar to an issue I found with a python mediawiki library: barrust/mediawiki#79
For private wikis you must login before you can get the api info. I'm not as familiar with Node so my understanding of the details of your code are limited, but I think you are doing a similar request before logging in. So the solution may be similar if you want mwn to be able to be used with private wikis.
Thanks!
Hi @jtmullen, mwn does indeed do an API query before logging in – which fetches the login token + siteinfo in a single call. Login token fetch works fine, but I see that querying siteinfo at the same time causes readapidenied
. Will look into fixing it; thanks for the bug report.
Awesome, thanks!
Could you check with the github version now? (You'll have to run npm install
and npm run build
after cloning, then inside node, you could do const {mwn} = require('.')
while in the cloned directory). ETA: npm run build will give a big list of "errors" – those are just type-check warnings, which are no problem.
When i tried it on a local docker-based private wiki, I was getting a weird issue of being able to login, but still getting readapidenied
on all further API calls, which is strange ...
Yeah for sure, I'll be able to give it a try tomorrow.
@siddharthvp I tried out the code on this commit: d1e3001339f4175476fb5d00a29b8c7e8a61cd43
I was able to login and read/edit pages with no errors on my private wiki, so from that standpoint it seems to work for me! Was there something specific that failed for you? I could try it out if that would be helpful.
If it worked without issues for you on a real private wiki, I think we're good here. I had only tested on localhost private wiki which I must have wrongly configured (it was giving readapidenied
even after login with a sysop account had succeeded). The tests are all green so there are no regressions with public wikis either.
Got it sounds good, I will use that version for my development. Just for reference, when would you be planning the next release version?
@jtmullen Released the new version!