Adding restrictions to API Keys using the gcloud alpha CLI

321 views Asked by At

Using gcloud alpha services It's now perfectly possible to generate keys programatically:

gcloud alpha services api-keys create

I can then enable the Maps JavaScript API using

gcloud services enable maps-backend.googleapis.com

At this point I need to set some HTTP referrer restrictions on that key but the services api-keys update command only updates an API key's metadata.

How do I proceed?

1

There are 1 answers

0
DazWilkin On BEST ANSWER

It looks (haven't tried the API) as though you can do this at create and update with --allowed-referrers:

https://cloud.google.com/sdk/gcloud/reference/alpha/services/api-keys/create

https://cloud.google.com/sdk/gcloud/reference/alpha/services/api-keys/update