Instead of filling them manually, as it is now.
For example, the paraminfo for action=edit contains:
{ "name": "token", "required": "", "tokentype": "csrf", "type": "string" }
Instead of filling them manually, as it is now.
For example, the paraminfo for action=edit contains:
{ "name": "token", "required": "", "tokentype": "csrf", "type": "string" }
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
Dynamically add appropriate tokens | pywikibot/core | master | +102 -45 |
Status | Subtype | Assigned | Task | ||
---|---|---|---|---|---|
Open | None | T78390 Load volatile information at run-time from the API (tracking) | |||
Open | None | T229364 CSRF token issues (tracking) | |||
Open | None | T78393 Load token types needed for each API module from the API | |||
Resolved | jayvdb | T85725 token methods should use the list of tokens in paraminfo |
T85725 covers the list of valid token types, while this one aims to have the correct token type automatically added to every request.
I'm not sure whether one of them blocks the other one.
Okay I've written this comment before I saw Ricordisamoa's comment above… so this comment doesn't make sense anymore.
I'm not sure about which tokens @Ricordisamoa is talking. All tokens accessible via action=tokens, action=query&meta=tokens and action=query&prop=info&intoken=… are now loaded initially. So if an extension is using something else it won't load its tokens but I think that is not feasible. But already before it has been loading all/almost all tokens at once, at least for the WMF wikis I think so maybe I'm missing something. Or it was specifically about that TOKENS_[123] are outdated but then it'd be a duplicate of T85725: token methods should use the list of tokens in paraminfo.
Ah, so this task would be resolved if api.py automatically added the necessary token, using paraminfo. Then site.py wouldnt need to specify which token to use, and this may even mean site.py adapts better to older versions where the token name is different from the new simplified token system.
Well unfortunately it was added after 1.21.1: http://wiki.kerbalspaceprogram.com/w/api.php?action=paraminfo&modules=edit&format=jsonfm
Change 201159 had a related patch set uploaded (by Ricordisamoa):
Detect and add the appropriate tokens to API requests
That patch might demonstrate it is easy to do 1.21+, but the hard part (pre 1.21) is ignored. If we remove the token related code from site.py , that patch only supports 1.21. If we leave token related code in site.py API calls, then what benefit is there in this patch?
We could remove the token-related code from site.py and add a fallback dict (API module, token types) for pre 1.21.