I'm unable to access an edit token for my media wiki site. Using the following code, I should be able to use the simpleMediWiki site to login, then request an edit token, then finally stage an edit. Unfortunately I'm getting an error that the 'edit' parameter is an unrecognized parameter:
{'error': {'info': "Unrecognized value for parameter 'action': token", 'code': 'unknown_action'}}
Here's my code:
from simplemediawiki import MediaWiki
wiki = MediaWiki('http://domain/api.php')
#the following logs me in
loginData = wiki.call({'action':'login', 'lgname':'myUserName','lgpassword':'myPassword'})
#The following is a resubmission of the login token
personalLoginData = wiki.call({'action':'login', 'lgname':'myUserName','lgpassword':'myPassword','lgtoken': loginData['login']['token']})
#the following is THE TROUBLESOME REQUEST FOR AN EDIT TOKEN
editTokenDict = wiki.call({'action':'tokens','type':'edit'})
#the following is an edit
results = wiki.call({'action':'edit','title':"ArticleTitle",'text':"This is the page",'tokens':editTokenDict['login']['token']})
I figured it out, the answer is that mediaWiki 1.19.2 didn't support this query option. The most recent release of mediaWiki supports this query option, however for everything else- you must use the query action to access an edit token. For example:
returnData = wiki.call({'action':'query','prop':'info', 'titles':'Main_Page','intoken':'edit'});
#keep in mind the edittoken is the same for every page, and that's why we preform the query action on the Main_Page
#then you must use the following to get the edittoken:
edittoken = returnData['query']['pages']['1']['edittoken']