gcloud alpha services api-keys create
Stay organized with collections
Save and categorize content based on your preferences.
- NAME
-
- gcloud alpha services api-keys create - create an API key with secure default restrictions
- SYNOPSIS
-
-
gcloud alpha services api-keys create[--annotations=[KEY=VALUE,…]] [--async] [--display-name=DISPLAY_NAME] [--key-id=KEY_ID] [--service-account=SERVICE_ACCOUNT] [--api-target=service=SERVICE[,methods=METHOD:…],[…]--allowed-application=[sha1_fingerprint=SHA1_FINGERPRINT,package_name=PACKAGE_NAME,…] |--allowed-bundle-ids=[ALLOWED_BUNDLE_IDS,…] |--allowed-ips=[ALLOWED_IPS,…] |--allowed-referrers=[ALLOWED_REFERRERS,…]] [GCLOUD_WIDE_FLAG …]
-
- DESCRIPTION
-
(ALPHA)Create an API key with secure default restrictions. - EXAMPLES
-
To create a key with display name and allowed IPs specified:
gcloudalphaservicesapi-keyscreate--display-name="test name"--allowed-ips=2620:15c:2c4:203:2776:1f90:6b3b:217,104.133.8.78To create a key with annotations:
gcloudalphaservicesapi-keyscreate--annotations=foo=bar,abc=defTo create a key with user-specified key ID:
gcloudalphaservicesapi-keyscreate--key-id="my-key-id"To create a key with allowed referrers restriction:
gcloudalphaservicesapi-keyscreate--allowed-referrers="https://www.example.com/*,http://sub.exampl\e.com/*"To create a key with allowed IOS app bundle IDs:
gcloudalphaservicesapi-keyscreate--allowed-bundle-ids=my.appTo create a key with allowed Android application:
gcloudalphaservicesapi-keyscreate--allowed-application=sha1_fingerprint=foo1,package_name=bar.foo--allowed-application=sha1_fingerprint=foo2,package_name=foo.barTo create a key with allowed API targets (service name only):
gcloudalphaservicesapi-keyscreate--api-target=service=bar.service.com--api-target=service=foo.service.comTo create a key with service account:
gcloudalphaservicesapi-keyscreate--service-account=my-service-accountTo create a key with allowed API targets (service and methods are specified):
gcloudalphaservicesapi-keyscreate--flags-file=my-flags.yamlThe content of 'my-flags.yaml' is as follows:
---api-target: service:"foo.service.com" ---api-target: service:"bar.service.com" methods: -"foomethod" -"barmethod"
- FLAGS
-
--annotations=[KEY=VALUE,…]- Annotations are key resource. Specify annotations as a key-value dictionary for small amounts of arbitrary client data.
--async- Return immediately, without waiting for the operation in progress to complete.
--display-name=DISPLAY_NAME- Display name of the key to create.
--key-id=KEY_ID- User-specified ID of the key to create.
--service-account=SERVICE_ACCOUNT- The email of the service account the key is bound to. If this field is specified, the key is a service account bound key and auth enabled.
--api-target=service=SERVICE[,methods=METHOD:…],[…]-
Repeatable. Specify service and optionally one or multiple specific methods.
Both fields are case insensitive. Methods can be specified as a colon-separated
list (e.g.,
--api-target="service=foo.service.com,methods=method1:method2"), or using--flags-file(see $ gcloud topic flags-file for details). -
At most one of these can be specified:
--allowed-application=[sha1_fingerprint=SHA1_FINGERPRINT,package_name=PACKAGE_NAME,…]-
Repeatable. Specify multiple allowed applications. The accepted keys are
sha1_fingerprintandpackage_name. --allowed-bundle-ids=[ALLOWED_BUNDLE_IDS,…]- iOS app's bundle ids that are allowed to use the key.
--allowed-ips=[ALLOWED_IPS,…]- A list of the caller IP addresses that are allowed to make API calls with this key.
--allowed-referrers=[ALLOWED_REFERRERS,…]- A list of regular expressions for the referrer URLs that are allowed to make API calls with this key.
- GCLOUD WIDE FLAGS
-
These flags are available to all commands:
--access-token-file,--account,--billing-project,--configuration,--flags-file,--flatten,--format,--help,--impersonate-service-account,--log-http,--project,--quiet,--trace-token,--user-output-enabled,--verbosity.Run
$ gcloud helpfor details. - NOTES
-
This command is currently in alpha and might change without notice. If this
command fails with API permission errors despite specifying the correct project,
you might be trying to access an API with an invitation-only early access
allowlist. These variants are also available:
gcloudservicesapi-keyscreategcloudbetaservicesapi-keyscreate