

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 驗證您的請求
<a name="tracking-identity-pool"></a>

建立追蹤器資源並準備好開始根據地理圍欄評估裝置位置後，請選擇驗證請求的方式：
+ 若要探索您可以存取 服務的方式，請參閱 [使用 Amazon Location Service 驗證](access.md)。
+ 如果您想要發佈具有未驗證請求的裝置位置，建議您使用 Amazon Cognito。

  **範例**

  下列範例顯示使用 Amazon Cognito 身分集區進行授權、使用 [AWS JavaScript SDK v3](https://aws.amazon.com/sdk-for-javascript/) 和 Amazon Location [Web](how-to-auth-helper.md#loc-sdk-auth-web)。

  ```
  import { LocationClient, BatchUpdateDevicePositionCommand } from "@aws-sdk/client-location";
  import { withIdentityPoolId } from "@aws/amazon-location-utilities-auth-helper";
  
  // Unauthenticated identity pool you created
  const identityPoolId = "us-east-1:1234abcd-5678-9012-abcd-sample-id";
  
  // Create an authentication helper instance using credentials from Cognito
  const authHelper = await withIdentityPoolId(identityPoolId);
  
  const client = new LocationClient({
    region: "us-east-1", // The region containing both the identity pool and tracker resource
    ...authHelper.getLocationClientConfig(), // Provides configuration required to make requests to Amazon Location
  });
  
  const input = {
    TrackerName: "ExampleTracker",
    Updates: [
      {
        DeviceId: "ExampleDevice-1",
        Position: [-123.4567, 45.6789],
        SampleTime: new Date("2020-10-02T19:09:07.327Z"),
      },
      {
        DeviceId: "ExampleDevice-2",
        Position: [-123.123, 45.123],
        SampleTime: new Date("2020-10-02T19:10:32Z"),
      },
    ],
  };
  
  const command = new BatchUpdateDevicePositionCommand(input);
  
  // Send device position updates
  const response = await client.send(command);
  ```