Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Api Key using gcloud?

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

like image 583
John Albano Avatar asked Mar 22 '18 22:03

John Albano


2 Answers

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.

like image 107
JMD Avatar answered Sep 22 '22 23:09

JMD


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.

enter image description here

like image 40
jpoehnelt Avatar answered Sep 19 '22 23:09

jpoehnelt