{
  "name": "401 на токене из кэша: новый токен и один повтор того же запроса",
  "description": "Токен из кэша, полученный более ранним вызовом, получил 401 — SDK забывает его, получает новый и повторяет запрос один раз без паузы, с тем же ключом идемпотентности; это не расходует maxRetries. Если и новый токен, полученный уже этим вызовом, получил 401 — ошибка authentication без следующего запроса токена.",
  "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": "listEventTypes",
      "args": {},
      "expect": {
        "result": {"data": [{"type": "member.enrolled", "version": 1}, {"type": "receipt.confirmed", "version": 1}]}
      }
    },
    {
      "operation": "adjustMemberPoints",
      "args": {"member": "01929c1e-0040-7040-8040-000000000040", "body": {"amount": 500, "reason_code": "goodwill"}},
      "expect": {
        "result": {
          "transaction_id": "01929c1e-0093-7093-8093-000000000093",
          "amount": 500,
          "member_delta": 500,
          "available": 1535
        }
      }
    },
    {
      "operation": "getMember",
      "args": {"member": "01929c1e-0040-7040-8040-000000000040"},
      "expect": {
        "error": {
          "class": "authentication",
          "status": 401,
          "code": "unauthenticated",
          "requestId": "01929c20-0008-7000-8000-000000000008"
        }
      }
    }
  ],
  "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/event-types",
        "headers": {
          "authorization": "Bearer lat_test_8NfzE9KomDFUk3lfJjBaLz0-9r7ns5Uo2tYUpmVlUcE",
          "accept": "application/json",
          "content-type": null,
          "idempotency-key": null,
          "loyal-merchant": null
        }
      },
      "response": {
        "status": 200,
        "headers": {
          "Content-Type": "application/json",
          "X-Request-Id": "01929c20-0002-7000-8000-000000000002",
          "Loyal-Environment": "sandbox"
        },
        "json": {"data": [{"type": "member.enrolled", "version": 1}, {"type": "receipt.confirmed", "version": 1}]}
      }
    },
    {
      "request": {
        "method": "POST",
        "url": "https://api.example.com/api/management/v1/members/01929c1e-0040-7040-8040-000000000040/point-adjustments",
        "headers": {
          "authorization": "Bearer lat_test_8NfzE9KomDFUk3lfJjBaLz0-9r7ns5Uo2tYUpmVlUcE",
          "accept": "application/json",
          "content-type": "application/json",
          "idempotency-key": "{{idempotency-key}}",
          "loyal-merchant": "01929c1e-0020-7020-8020-000000000020"
        },
        "json": {"amount": 500, "reason_code": "goodwill"}
      },
      "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"
        }
      }
    },
    {
      "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-0004-7000-8000-000000000004",
          "Loyal-Environment": "sandbox",
          "Cache-Control": "no-store",
          "Pragma": "no-cache"
        },
        "json": {
          "access_token": "lat_test_qvV4pHbQkRVZU2JGlM8sDbPPc66wzxY0WJUD2RPnjjA",
          "token_type": "Bearer",
          "expires_in": 3600,
          "scope": "merchants programs organization members webhooks reports"
        }
      }
    },
    {
      "request": {
        "method": "POST",
        "url": "https://api.example.com/api/management/v1/members/01929c1e-0040-7040-8040-000000000040/point-adjustments",
        "headers": {
          "authorization": "Bearer lat_test_qvV4pHbQkRVZU2JGlM8sDbPPc66wzxY0WJUD2RPnjjA",
          "accept": "application/json",
          "content-type": "application/json",
          "idempotency-key": "{{idempotency-key}}",
          "loyal-merchant": "01929c1e-0020-7020-8020-000000000020"
        },
        "json": {"amount": 500, "reason_code": "goodwill"}
      },
      "response": {
        "status": 201,
        "headers": {
          "Content-Type": "application/json",
          "X-Request-Id": "01929c20-0005-7000-8000-000000000005",
          "Loyal-Environment": "sandbox"
        },
        "json": {
          "transaction_id": "01929c1e-0093-7093-8093-000000000093",
          "amount": 500,
          "member_delta": 500,
          "available": 1535
        }
      }
    },
    {
      "request": {
        "method": "GET",
        "url": "https://api.example.com/api/management/v1/members/01929c1e-0040-7040-8040-000000000040",
        "headers": {
          "authorization": "Bearer lat_test_qvV4pHbQkRVZU2JGlM8sDbPPc66wzxY0WJUD2RPnjjA",
          "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-0006-7000-8000-000000000006",
          "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-0006-7000-8000-000000000006"
        }
      }
    },
    {
      "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-0007-7000-8000-000000000007",
          "Loyal-Environment": "sandbox",
          "Cache-Control": "no-store",
          "Pragma": "no-cache"
        },
        "json": {
          "access_token": "lat_test_SchL8XCl7Pw6DG1_A2llGzD_lLdVDTQhAU_Q8mQ64RI",
          "token_type": "Bearer",
          "expires_in": 3600,
          "scope": "merchants programs organization members webhooks reports"
        }
      }
    },
    {
      "request": {
        "method": "GET",
        "url": "https://api.example.com/api/management/v1/members/01929c1e-0040-7040-8040-000000000040",
        "headers": {
          "authorization": "Bearer lat_test_SchL8XCl7Pw6DG1_A2llGzD_lLdVDTQhAU_Q8mQ64RI",
          "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-0008-7000-8000-000000000008",
          "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-0008-7000-8000-000000000008"
        }
      }
    }
  ],
  "sleeps": []
}
