API:Tokens (action)
Appearance
| Cette page fait partie de la documentation de l'API MediaWiki Action. |
| tokens | ||
|---|---|---|
| Gets tokens for data-modifying actions. Ce module ne peut pas être utilisé comme générateur. | ||
| Préfixe | ||
| Droits exigés | aucun | |
| POST seulement ? | Non | |
| Aide générée | Version actuelle | |
| Ajouté en version |
| |
Pour the current method of obtaining tokens via a meta module, voir : API:Tokens.
action=tokens was deprecated in MW 1.24 and removed in 1.37. Utiliser action=query&meta=tokens à la place. (See API:Tokens.)Tokens can be obtained using action=tokens. These tokens can then be used in other API requests.
Paramètres
type: le type de jeton demandé.blockdeleteeditemailimportmoveoptionspatrolprotectrollbackunblockwatch
The Central Auth extension on MediaWiki servers adds the following tokens:deleteglobalaccountsetglobalaccountstatus
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>
Les erreurs possibles comprennent :
- Valeur non reconnue du paramètre type: value.
- ⧼apiwarn-tokennotallowed⧽
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.