I am using "gcloud projects create [project-id]" to create a project, and then "gcloud services enable customsearch.googleapis.com" to enable custom search.
Now I want to create an Api Key but don't see any way to do that. Is it possible?
Thanks
It appears that you have to create the API key via the GCP Console, however there is a Feature Request for this functionality to be provided in the future so that API keys can be created using gcloud. There is not ETA but any progress can be followed on the above link. For now you can use the GCP Console:
Towards the bottom of this documentation link on the ‘API key’ section you can click on ‘GET A KEY’. A new window will pop up asking you to select your project. Select the project you want the key for and click Next. A new API key will be created for your project.
You can manage your API keys and improve their security via the API Console Credentials menu which can also be used to create API keys.
You should also read the following documentation link which explains a bit more about the pros and cons of using API keys and their limitations which can be overcome using Service Accounts.
There is a gcloud alpha command available currently.
https://cloud.google.com/sdk/gcloud/reference/alpha/services/api-keys/create
gcloud alpha services api-keys create --display-name="test name"
Check out the examples.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With