> ## Documentation Index
> Fetch the complete documentation index at: https://docs.localpayment.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 获取访问令牌

要访问我们的任何服务，您必须先通过获取访问令牌完成身份验证。请使用您的仪表盘用户名和密码来请求令牌。

> **令牌过期**
>
> 出于安全原因，访问令牌的有效期为 60 分钟。

> **重要的**
>
> 您的 IP 地址必须在[白名单](https://docs.localpayment.com/zh/docs/dashboard-whitelist-your-ips.md)中，才能成功生成令牌。


## OpenAPI

````yaml openapi/zh/localpayment.json POST /api/token/
openapi: 3.1.0
info:
  version: '1.0'
  title: Localpayment
  contact:
    name: Support
    url: mailto:support@localpayment.com
servers:
  - url: https://api.stage.localpayment.com
    description: Stage
security:
  - token: []
paths:
  /api/token/:
    post:
      summary: 获取访问令牌
      operationId: get-token
      requestBody:
        description: ''
        content:
          application/json:
            schema:
              type: object
              properties:
                username:
                  type: string
                  description: 您的 Localpayment 用户名。该用户名已在入驻流程中提供给您。
                password:
                  type: string
                  description: 您的 Localpayment 密码。该密码已在入驻流程中提供给您。
              required:
                - username
                - password
              x-examples:
                Example 1:
                  username: USERNAME_PROVIDED_BY_LOCALPAYMENT
                  password: PASSWORD_PROVIDED_BY_LOCALPAYMENT
            examples:
              200 - Access Token:
                value:
                  username: <USERNAME>
                  password: <PASSWORD>
              400 - Username field is required.:
                value:
                  password: '{{password}}'
              400 - Not a valid string.:
                value:
                  username: string
                  password: []
              400 - Password field is required.:
                value:
                  username: user@example.com
              400 - Required fields missing.:
                value: {}
              401 - No active account found with the given credentials:
                value:
                  username: user@example.com
                  password: <PASSWORD>
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  refresh:
                    type: string
                    description: 用于获取新访问令牌的刷新令牌。
                  access:
                    type: string
                    description: 用于验证对 Localpayment 服务的请求的访问令牌。
                required:
                  - refresh
                  - access
                x-examples:
                  Example 1:
                    refresh: >-
                      eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTczNTMxOTkyOSwianRpIjoiZWUxMDE3MTUwY2JhNGM1NTg0MjYyZmRkZTdiOThiNGQiLCJ1c2VyX2lkIjoxMDAwLCJzdXBlcnVzZXIiOnRydWUsImlzX3N0YWZmIjp0cnVlLCJyb2xlcyI6WyJBTEwiXSwiY291bnRyaWVzIjpbIkFMTCJdLCJjb21wYW55IjoiQUxMIiwiY2xpZW50X2NvZGUiOiJBTEwiLCJwZXJtaXNzaW9ucyI6W119.6siymomk9sMCQ72yMvHGUO4h-cxpNgQXorcM5kYO7o4
                    access: >-
                      eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzM1MjMzODI5LCJqdGkiOiJiMDRmNzQ3YWE4Mjg0YjM0YmMwN2Y4ZjVkOWM0NWFjOCIsInVzZXJfaWQiOjEwMDAsInN1cGVydXNlciI6dHJ1ZSwiaXNfc3RhZmYiOnRydWUsInJvbGVzIjpbIkFMTCJdLCJjb3VudHJpZXMiOlsiQUxMIl0sImNvbXBhbnkiOiJBTEwiLCJjbGllbnRfY29kZSI6IkFMTCIsInBlcm1pc3Npb25zIjpbXX0.sWOLKFxCcXQkUcPvTjYceXBp39lqEnH7GrEhDF3-Snc
              examples:
                200 - Access Token:
                  value:
                    refresh: >-
                      eyJ0eXAiOiJKV1QiLCJhbGccM5kYO7o4iOiJIU18jaiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTczNTMxOTkyOSwianRpIjoiZWUxMDE3MTUwY2JhNGM1NTg0MjYyZmRkZTdiOThiNGQiLCJ1c2VyX2lkIjoxMDAwLCJzdXBlcnVzZXIiOnRydWUsImlzX3N0YWZmIjp0cnVlLCJybaCIsImV4cCI62xlcyI6WyJBTEwiXSwiY291bnRyaWVzIjpbIkFMTCJdLCJjb21wYW55IjoiQUxMIiwiY2xpZW50X2NvZGUiOiJBNzaW9uTEwiLCJwZXJtaXcyI6W119.6siymomkQ72yMvHGU9sMCO4h-cxpNgQXor
                    access: >-
                      eyJ0eXAiOiJKV1QiLCJhJIUzI1NiJ9.eyJ0b2tlbl90eXBlIbGciOijoiYWNjZXNzIiwiZXhwIjoxNzM1MjMzODI5LCJqdGkiOiJiMDRmNzQ3YWEjOCIsIn4Mjg0YjM0YmMwN2Y4ZjVkOWM0NWFVzZXJfaWQiOjEwMDAsInN1cGVydXNlciI6dHJ1ZSwiaXNfc3RhZmYiOnRy3VudHJpZXMiOljpbIkFsiQUxMIl0sImNvbXBhbnkiOiJBTEwiLCJjbGllbnRfY29kZSI6IkFMTCIsInBlcm1pc3Npb25zIjpdWUsInJvbGVzIMTCJdLlqEnH7GrECJjbbXX0.sWOLKFxCcXQkUcPvTjYceXBp39hDF3-Snc
        '400':
          description: 错误的请求。
          content:
            application/json:
              schema:
                type: object
                properties:
                  username:
                    type: array
                    description: 您的 Localpayment 用户名。该用户名已在入驻流程中提供给您。
                    items:
                      type: string
                  password:
                    type: array
                    description: 您的 Localpayment 密码。该密码已在入驻流程中提供给您。
                    items:
                      type: string
                x-examples:
                  Example 1:
                    username:
                      - This field is required.
                    password:
                      - This field is required.
              examples:
                400 - Username field is required.:
                  value:
                    username:
                      - This field is required.
                400 - Not a valid string.:
                  value:
                    password:
                      - Not a valid string.
                400 - Password field is required.:
                  value:
                    password:
                      - This field is required.
                400 - Required fields missing.:
                  value:
                    username:
                      - This field is required.
                    password:
                      - This field is required.
        '401':
          description: 未经授权
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    description: 更多回复详情。
                required:
                  - detail
                x-examples:
                  Example 1:
                    detail: No active account found with the given credentials
              examples:
                401 - No active account found with the given credentials:
                  value:
                    detail: No active account found with the given credentials
                401 - Invalid IP for user.:
                  value:
                    detail: >-
                      Invalid IP for user. Please validate that 189.200.97.11 is
                      whitelisted in your account settings.
      security: []
      servers:
        - url: https://api.stage.localpayment.com
          description: Stage
components:
  securitySchemes:
    token:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.