{
  "name": "401 на токене, полученном этим же вызовом, — authentication без второго запроса токена",
  "description": "Хранилище пустое: getLocation сам получает токен, первая попытка получает 503 и повторяется через 500 мс с тем же токеном (он уже в кэше, но получен этим вызовом), повтор получает 401. Только что выданный токен отвергнут — обновлять его бессмысленно: ошибка authentication, запроса нового токена нет; последний ответ вызова — этот 401.",
  "client": {
    "api": "management",
    "credential": {
      "clientCredentials": {
        "clientId": "lc_test_4b9ac4f5d6cc6783a2044a5a",
        "clientSecret": "lcs_test__A75hCwHKWYA61AD1WKWOkjtKvU2hRnSKCx_YVFfVos"
      }
    },
    "baseUrl": "https://api.example.com",
    "merchant": "01929c1e-0020-7020-8020-000000000020"
  },
  "calls": [
    {
      "operation": "getLocation",
      "args": {"location": "01929c1e-0030-7030-8030-000000000030"},
      "expect": {
        "error": {
          "class": "authentication",
          "status": 401,
          "code": "unauthenticated",
          "requestId": "01929c20-0003-7000-8000-000000000003",
          "idempotencyKey": null
        },
        "meta": {"operationId": "getLocation", "method": "GET", "path": "/api/management/v1/locations/{location}", "status": 401}
      }
    }
  ],
  "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"}
      },
      "response": {
        "status": 200,
        "headers": {
          "Content-Type": "application/json",
          "X-Request-Id": "01929c20-0001-7000-8000-000000000001",
          "Loyal-Environment": "sandbox",
          "Cache-Control": "no-store",
          "Pragma": "no-cache"
        },
        "json": {
          "access_token": "lat_test_8NfzE9KomDFUk3lfJjBaLz0-9r7ns5Uo2tYUpmVlUcE",
          "token_type": "Bearer",
          "expires_in": 3600,
          "scope": "merchants programs organization members webhooks reports"
        }
      }
    },
    {
      "request": {
        "method": "GET",
        "url": "https://api.example.com/api/management/v1/locations/01929c1e-0030-7030-8030-000000000030",
        "headers": {
          "authorization": "Bearer lat_test_8NfzE9KomDFUk3lfJjBaLz0-9r7ns5Uo2tYUpmVlUcE",
          "accept": "application/json",
          "content-type": null,
          "idempotency-key": null,
          "loyal-merchant": "01929c1e-0020-7020-8020-000000000020"
        }
      },
      "response": {
        "status": 503,
        "headers": {
          "Content-Type": "application/problem+json",
          "X-Request-Id": "01929c20-0002-7000-8000-000000000002",
          "Loyal-Environment": "sandbox"
        },
        "json": {
          "type": "urn:loyal:problem:http_503",
          "title": "Service Unavailable",
          "status": 503,
          "code": "http_503",
          "request_id": "01929c20-0002-7000-8000-000000000002"
        }
      }
    },
    {
      "request": {
        "method": "GET",
        "url": "https://api.example.com/api/management/v1/locations/01929c1e-0030-7030-8030-000000000030",
        "headers": {
          "authorization": "Bearer lat_test_8NfzE9KomDFUk3lfJjBaLz0-9r7ns5Uo2tYUpmVlUcE",
          "accept": "application/json",
          "content-type": null,
          "idempotency-key": null,
          "loyal-merchant": "01929c1e-0020-7020-8020-000000000020"
        }
      },
      "response": {
        "status": 401,
        "headers": {
          "Content-Type": "application/problem+json",
          "X-Request-Id": "01929c20-0003-7000-8000-000000000003",
          "Loyal-Environment": "sandbox",
          "WWW-Authenticate": "Bearer realm=\"loyal\""
        },
        "json": {
          "type": "urn:loyal:problem:unauthenticated",
          "title": "A valid access token is required.",
          "status": 401,
          "code": "unauthenticated",
          "request_id": "01929c20-0003-7000-8000-000000000003"
        }
      }
    }
  ],
  "sleeps": [500]
}
