-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API key #7347
Labels
Comments
Hi @jonhassall, this is a great request. The API key docs are hard to find because not every API supports them. For the APIs which ARE supported, here's how you could take advantage of them: use Google\Cloud\RecaptchaEnterprise\V1\Client\RecaptchaEnterpriseServiceClient;
use Google\Cloud\RecaptchaEnterprise\V1\ListKeysRequest;
use Google\ApiCore\InsecureCredentialsWrapper;
// Create a client.
$recaptcha = new RecaptchaEnterpriseServiceClient([
// STEP 1: use insecure credentials wrapper to bypass application default creds
'credentials' => new InsecureCredentialsWrapper(),
]);
// Prepare the request message.
$formattedParent = RecaptchaEnterpriseServiceClient::projectName('[PROJECT]');
$request = (new ListKeysRequest())->setParent($formattedParent);
// Call the API and handle any network failures.
/** @var PagedListResponse $response */
$response = $recaptchaEnterpriseServiceClient->listKeys($request, [
// STEP 2: Pass in the API key with each RPC call as a "Call Option"
'headers' => ['x-goog-api-key' => ['[API-KEY]']],
]);
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please improve your documentation on using an API key with your library.
The text was updated successfully, but these errors were encountered: