API:Tokens (action)

From mediawiki.org
Jump to navigation Jump to search
This page is a translated version of the page API:Tokens (action) and the translation is 40% complete.
Other languages:
Deutsch • ‎Deutsch (Sie-Form) • ‎English • ‎Türkçe • ‎dansk • ‎español • ‎français • ‎italiano • ‎polski • ‎português • ‎română • ‎русский • ‎العربية • ‎کوردی • ‎ไทย • ‎中文 • ‎日本語
Pour the current method of obtaining tokens via a meta module, voir : API:Tokens.
Since MW 1.24, the action=tokens is deprecated and includes a warning "Please use action=query&meta=tokens instead".

Tokens can be obtained using action=tokens. These tokens can then be used in other API requests.

Paramètres

  • type: the type of token requested.
    • block
    • delete
    • edit
    • email
    • import
    • move
    • options
    • patrol
    • protect
    • rollback
    • unblock
    • watch

      The Central Auth extension on MediaWiki servers adds the following tokens:
    • deleteglobalaccount
    • setglobalaccountstatus

Exemples

Getting an edit token (default behavior)

Résultat
<?xml version="1.0"?>
<api>
  <tokens edittoken="6c82e3a4f17f52ff1e2e4a16b64fed10+\" />
</api>

Getting several tokens at once

Résultat
<?xml version="1.0"?>
<api>
  <tokens edittoken="6c82e3a4f17f52ff1e2e4a16b64fed10+\" emailtoken="6c82e3a4f17f52ff1e2e4a16b64fed10+\" patroltoken="0eaa2666f8c6c0779c43acbdf9703c4a+\" watchtoken="22dff2c0b0c1bef9ad34673b81b91f22+\" />
</api>

Erreurs possibles

In addition to the usual errors, other errors may be returned in the following format:

<?xml version="1.0"?>
<api>
   <warnings>
      <tokens>Valeur non reconnue du paramètre <var>type</var>: test.</tokens>
   </warnings>
   <tokens/>
</api>

Possible errors include:

  • Valeur non reconnue du paramètre type: value.
  • L’action « xxx » n’est pas autorisée pour l’utilisateur actuel.

Failing to urlencode the token can result in an invalid token error.

Note importante

You need to send the cookie obtained in the login phase when you call the api with the "tokens" action; otherwise you get the cryptic "readapidenied" error.

Documentation de l'API


action=tokens

(main | tokens)
  • This module is deprecated.
  • This module requires read rights.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Get tokens for data-modifying actions.

This module is deprecated in favor of action=query&meta=tokens.

Parameter:
type

Types of token to request.

Values (separate with | or alternative): block, createaccount, csrf, delete, deleteglobalaccount, edit, email, import, login, move, options, patrol, protect, rollback, setglobalaccountstatus, unblock, userrights, watch
Default: edit
Examples:
Retrieve an edit token (the default).
api.php?action=tokens [open in sandbox]
Retrieve an email token and a move token.
api.php?action=tokens&type=email|move [open in sandbox]