API:Login/zh

MediaWiki API可能会要求您的应用程序或客户端提供经过身份验证的用户凭据并登录（a）查询信息或进行数据修改操作（b）进行比请求限制较大的查询.

两种身份验证方法
有两种方法可以对MediaWiki Action API进行身份验证：

方法1.登录
Bot and other non-interactive applications should use owner-only OAuth consumers if available as it is more secure. If not available or not applicable to the client, the  action may be used with bot passwords.

方法2. 客户端登录
Interactive applications such as custom editors or patrolling applications that provide a service without intending to fully replace the website or mobile apps that aim to completely replace access to the web-based user interface should use the  action. However, one should prefer using if it is available for authenticating the tool, as it is easier and more secure. 该模块在MediaWiki 1.27版本开始可用.

POST请求
通过在上述请求中获得令牌登录.

Example 2: Process for a wiki with special authentication extensions
A wiki with special authentication extensions such as (captchas),,  (two factor authentication), may have a more complicated authentication process. Specific fields might also be required in that case, the description of which could be fetched from the query.

步骤3：两步验证
Note: In certain cases it's possible to receive a  response, for example if the OpenID Connect extension had no mapping for the OpenID account to any local user.In this case the client might restart the login process from the beginning or might switch to account creation, in either case passing the loginpreservestate or createpreservestate parameter to preserve some state.

附加提醒

 * 在允许匿名编辑的wiki上，不登录就可以编辑；但我们强烈推荐您先登录. 在非开放wiki上，使用任何API功能都需要登录.
 * It is recommended to create a separate user account for your application. This is especially important if your application is carrying out automated editing or invoking large or performance-intensive queries. With that, it is easy to track changes made by the application and apply special rights to the application's account.
 * If you are sending a request that should be made by a logged-in user, add  parameter to the request you are sending in order to check whether the user is logged in. 如果用户未登录，将返回 错误代码.
 * 要检查帐户是否具有机器人权限，请在请求中添加 参数. 如果该帐户没有机器人权限，则将返回 错误代码.

参见

 * - 返回有关当前登录用户的信息