API:tokens (操作)

From mediawiki.org
This page is a translated version of the page API:Tokens (action) and the translation is 56% complete.
the current method of obtaining tokens via a meta moduleについては、API:Tokens を参照してください。
action=tokens was deprecated in MW 1.24 and removed in 1.37. Use action=query&meta=tokens instead. (See API:トークン .)

トークンは action=tokens を使用して取得できます。取得したトークンはその他の API リクエストで使用できます。

パラメーター

  • type: リクエストするトークンの種類。
    • 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

Getting an edit token (default behavior)

結果
<?xml version="1.0"?>
<api>
  <tokens edittoken="6c82e3a4f17f52ff1e2e4a16b64fed10+\" />
</api>

Getting several tokens at once

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

起こりうるエラー

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

<?xml version="1.0"?>
<api>
   <warnings>
      <tokens>Unrecognized value for parameter <var>type</var>: test.</tokens>
   </warnings>
   <tokens/>
</api>

以下のエラーが発生する場合があります:

  • Unrecognized value for parameter type: value.
  • ⧼apiwarn-tokennotallowed⧽

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

重要な注意事項

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.

APIの説明文書


Module "tokens" not found.