Skip to content

Commit de20ff4

Browse files
committed
feat: update apikey sample for client option support
1 parent 5ad66db commit de20ff4

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

auth/src/auth_cloud_apikey.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ function auth_cloud_apikey(string $projectId, string $location, string $apiKey):
4444

4545
// Create a client.
4646
$productSearchClient = new ProductSearchClient([
47-
// STEP 1: Use an insecure credentials wrapper to bypass the application default credentials.
48-
'credentials' => new InsecureCredentialsWrapper(),
47+
'apiKey' => $apiKey,
4948
]);
5049

5150
// Prepare the request message.
@@ -55,10 +54,7 @@ function auth_cloud_apikey(string $projectId, string $location, string $apiKey):
5554
// Call the API and handle any network failures.
5655
try {
5756
/** @var PagedListResponse $response */
58-
$response = $productSearchClient->listProducts($request, [
59-
// STEP 2: Pass in the API key with each RPC call as a "Call Option"
60-
'headers' => ['x-goog-api-key' => [$apiKey]],
61-
]);
57+
$response = $productSearchClient->listProducts($request);
6258

6359
/** @var Product $element */
6460
foreach ($response as $element) {

0 commit comments

Comments
 (0)