

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# Mengautentikasi permintaan Anda
<a name="tracking-identity-pool"></a>

Setelah Anda membuat sumber daya pelacak dan Anda siap untuk mulai mengevaluasi posisi perangkat terhadap geofences, pilih bagaimana Anda akan mengautentikasi permintaan Anda:
+ Untuk menjelajahi cara Anda dapat mengakses layanan, lihat[Autentikasi dengan Amazon Location Service](access.md).
+ Jika Anda ingin mempublikasikan posisi perangkat dengan permintaan yang tidak diautentikasi, Anda mungkin ingin menggunakan Amazon Cognito.

  **Contoh**

  Contoh berikut menunjukkan penggunaan kumpulan identitas Amazon Cognito untuk otorisasi, menggunakan [AWS JavaScript SDK v3,](https://aws.amazon.com/sdk-for-javascript/) dan Lokasi Amazon. [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);
  ```