Last modified: 2014-08-27 15:44:54 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T40717, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 38717 - token api should allow type parameters for any action name which requires a token
token api should allow type parameters for any action name which requires a t...
Status: RESOLVED WONTFIX
Product: MediaWiki
Classification: Unclassified
API (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-26 17:35 UTC by Jon
Modified: 2014-08-27 15:44 UTC (History)
7 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Jon 2012-07-26 17:35:15 UTC
Playing with the API sandbox, I noticed there are inconsistencies in the API which should be fixed - it seemed
logical to me as newbie that via the tokens api I should be able to pass
a 'type' parameter that had values emailuser, rollback, upload, userrights, filerevert, login 

as these are valid values of action and for actions such as edit, watch - I can supply edit or watch to get a token
e.g. /w/api.php?action=tokens&format=json&type=watch

However this is not the case with these actions.

e.g. /w/api.php?action=tokens&format=json&type=rollback
returns
{"warnings":{"tokens":{"*":"Unrecognized value for parameter 'type': rollback"}},"tokens":[]}


I believe this makes it difficult to understand the correct way to request a token as the user must deduce where they get the relevant token.
Comment 1 Jon 2012-07-26 17:49:45 UTC
Also see https://gerrit.wikimedia.org/r/#/c/16191/
Comment 2 Umherirrender 2012-07-27 14:15:19 UTC
Each module has a short hint where you can get the token from, some needs a update to reflect the new module action=tokens

Getting all tokens over action=tokens is not possible, because some modules needs extra information to create the token.

The rollback token is generated using the user and title of the edit you want to rollback, so this is not unique per session.

Token for emailuser exist as type=email

userrights needs the username where rights should change

upload and filerevert needs a edit token, no special token, maybe adding as alias?
Comment 3 Jon 2012-07-27 23:10:19 UTC
Aliases sound like a great idea.

I think for those which require more information it should be possible to provide those. e.g. in the case of rollback why not require the username and title of the article?
Comment 4 Jon 2014-08-08 16:38:45 UTC
I just hit this bug again. I needed to retrieve userrights and tried get token. Sigh.
Comment 5 Kunal Mehta (Legoktm) 2014-08-26 19:41:31 UTC
Marking as WORKSFORME because with the new API token handling you just use one token for nearly everything.
Comment 6 Jon 2014-08-26 19:44:27 UTC
Legoktm can you point me at a patch/wikipage for new API handling?
I can't seem to request a userrights, rollback or various other tokens that I listed in #c1 on
http://en.wikipedia.beta.wmflabs.org/wiki/Special:ApiSandbox so I'm not sure why you've marked this as it working for you.
Comment 7 Kunal Mehta (Legoktm) 2014-08-26 19:46:10 UTC
You don't need different tokens for different things, just one token for everything (except for login/createaccount/CentralAuth). See <http://en.wikipedia.beta.wmflabs.org/w/api.php?action=query&meta=tokens> and I2793a3f2dd64a4bebb0b4d065e09af1e9f63fb89.
Comment 8 Jon 2014-08-26 19:47:13 UTC
Nice. Will we drop support for the named tokens then? Their existence is kind of confusing now...
Comment 9 Kunal Mehta (Legoktm) 2014-08-26 19:49:36 UTC
They are deprecated, but still supported for backwards-compatability. I'm not sure what anomie's plan/timeline on removing them is.
Comment 10 Brad Jorsch 2014-08-26 20:13:59 UTC
More specifically, most actions will use the token returned by action=query&meta=tokens (&type=csrf, but that's the default). Some will still use custom types, but the type needed is now clearly indicated by the output of action=help and is also indicated in a machine-readable fashion by action=paraminfo.

As for the timeline on removing the now-deprecated methods of fetching tokens, uses of those methods will be logged to api-feature-usage.log on fluorine. Once we start on MediaWiki 1.25 we'll monitor that log and decide on removal based on that.

Technically this bug is probably WONTFIX rather than WORKSFORME, but I'll leave it up to you what RESOLVED reason to put on it.
Comment 11 Jon 2014-08-27 15:44:54 UTC
for clarity then.. thanks for summarising :)

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links