Page MenuHomePhabricator

Warning message is unclear when using a callback parameter while trying to get a token
Closed, DeclinedPublic

Description

Author: diwanshipandey

Description:
Intention:
I wanted to get the edit token of a Wikipedia:Sandbox page to edit it through Codecademy.

Steps to Reproduce:

  1. I made a tutorial on codecademy for wikipedia API to get the edit token of a Wikipedia:Sandbox page
  2. The link to the tutorial is : http://www.codecademy.com/courses/web-intermediate-en-BLea4/4/1

Actual Results:
The api is returning a warning saying : "Unrecognized value for parameter 'intoken': edit"

Expected Results:
There is not a clear message when using a callback parameter while trying to get a token

Reproducible: Didn't try


Version: 1.23.0
Severity: normal
Whiteboard: aklapper-moreinfo
URL: http://www.codecademy.com/courses/web-intermediate-en-BLea4/4/1

Details

Reference
bz60195

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 3:04 AM
bzimport set Reference to bz60195.
bzimport added a subscriber: Unknown Object (MLST).

The documentation for the callback parameters includes the sentence "For safety, all user-specific data will be restricted.", this includes also tokens from prop=info, why 'edit' is not a valid value for intoken in that situation.

Same for action=tokens.

When you are on a mediawiki page, you can use mw.user.tokens.get('edittoken') to get a token.

When you are on a mediawiki page, you can get a token also over mw.api.getToken, have a look at mediawiki.api.js to see, how this module will do it. The following comment was found in that file:

Due to the API assuming we're logged out if we pass the callback-parameter,
we have to disable jQuery's callback system, and instead parse JSON string,
// by setting 'jsonp' to false.

maybe that helps

Diwanshi: Do Umherirrender's comments help sufficiently? Or are there more clarifications you would like to see in the documentation? If so, what?

diwanshipandey wrote:

(In reply to Andre Klapper from comment #3)

Diwanshi: Do Umherirrender's comments help sufficiently? Or are there more
clarifications you would like to see in the documentation? If so, what?

Andre: Yes Umherirrender's comment helped in understanding the problem. As i am not using mediawiki instance so can't use mw.api.getToken. Sorry for replying so late.

(In reply to Diwanshi Pandey from comment #4)

(In reply to Andre Klapper from comment #3)

Diwanshi: Do Umherirrender's comments help sufficiently? Or are there more
clarifications you would like to see in the documentation? If so, what?

Andre: Yes Umherirrender's comment helped in understanding the problem. As i
am not using mediawiki instance so can't use mw.api.getToken. Sorry for
replying so late.

I still think there is a (low-priority) bug here, as we shouldn't return a "parameter doesn't exist" error for a "parameter disabled" error. Error messages should reflect their actual causes, otherwise it confuses people.