{
  "name": "Ошибки точки выдачи токенов в формате RFC 6749 — класс oauth; неудача не кэшируется",
  "description": "Токен запрашивается формой с HTTP Basic, скоупы — через пробел в порядке, заданном клиентом. 401 invalid_client и 400 invalid_scope не повторяются; следующий вызов снова запрашивает токен.",
  "client": {
    "api": "management",
    "credential": {
      "clientCredentials": {
        "clientId": "lc_test_4b9ac4f5d6cc6783a2044a5a",
        "clientSecret": "lcs_test__A75hCwHKWYA61AD1WKWOkjtKvU2hRnSKCx_YVFfVos",
        "scopes": ["merchants", "audit"]
      }
    },
    "baseUrl": "https://api.example.com"
  },
  "calls": [
    {
      "operation": "listMerchants",
      "args": {},
      "expect": {
        "error": {
          "class": "oauth",
          "status": 401,
          "code": null,
          "oauthError": "invalid_client",
          "requestId": "01929c20-0001-7000-8000-000000000001"
        }
      }
    },
    {
      "operation": "listMerchants",
      "args": {},
      "expect": {
        "error": {
          "class": "oauth",
          "status": 400,
          "code": null,
          "oauthError": "invalid_scope",
          "requestId": "01929c20-0002-7000-8000-000000000002"
        }
      }
    }
  ],
  "exchanges": [
    {
      "request": {
        "method": "POST",
        "url": "https://api.example.com/api/management/v1/oauth/token",
        "headers": {
          "authorization": "Basic bGNfdGVzdF80YjlhYzRmNWQ2Y2M2NzgzYTIwNDRhNWE6bGNzX3Rlc3RfX0E3NWhDd0hLV1lBNjFBRDFXS1dPa2p0S3ZVMmhSblNLQ3hfWVZGZlZvcw==",
          "accept": "application/json",
          "content-type": "application/x-www-form-urlencoded",
          "idempotency-key": null,
          "loyal-merchant": null
        },
        "form": {"grant_type": "client_credentials", "scope": "merchants audit"}
      },
      "response": {
        "status": 401,
        "headers": {
          "Content-Type": "application/json",
          "X-Request-Id": "01929c20-0001-7000-8000-000000000001",
          "Loyal-Environment": "sandbox",
          "Cache-Control": "no-store",
          "WWW-Authenticate": "Basic realm=\"loyal\""
        },
        "json": {"error": "invalid_client", "error_description": "Client authentication failed."}
      }
    },
    {
      "request": {
        "method": "POST",
        "url": "https://api.example.com/api/management/v1/oauth/token",
        "headers": {
          "authorization": "Basic bGNfdGVzdF80YjlhYzRmNWQ2Y2M2NzgzYTIwNDRhNWE6bGNzX3Rlc3RfX0E3NWhDd0hLV1lBNjFBRDFXS1dPa2p0S3ZVMmhSblNLQ3hfWVZGZlZvcw==",
          "accept": "application/json",
          "content-type": "application/x-www-form-urlencoded",
          "idempotency-key": null,
          "loyal-merchant": null
        },
        "form": {"grant_type": "client_credentials", "scope": "merchants audit"}
      },
      "response": {
        "status": 400,
        "headers": {
          "Content-Type": "application/json",
          "X-Request-Id": "01929c20-0002-7000-8000-000000000002",
          "Loyal-Environment": "sandbox",
          "Cache-Control": "no-store"
        },
        "json": {"error": "invalid_scope", "error_description": "The client may request only: merchants programs."}
      }
    }
  ],
  "sleeps": []
}
