This page describes how to use the API key methods to:
- List API keys in a project
- Get metadata for an API key
- Get the key string
- Get the key name and project for a key string
Listing API keys in a project
You can get a list of all the keys owned by a Google Cloud project with the
ListKeys method:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ 'https://apikeys.googleapis.com/v2/projects/PROJECT_NUMBER/locations/global/keys'
On success, you get a response similar to the following:
{
"keys": [
{
"name": "projects/12345678/locations/global/keys/2885bf87-5b84-47fa-92af-08c3e9337349",
"displayName": "API key 2",
"createTime": "2019-05-29T22:07:22.036Z",
"uid": "2885bf87-5b84-47fa-92af-08c3e9337349",
"updateTime": "2019-05-29T22:07:22.058623Z",
"restrictions": {
"androidKeyRestrictions": {}
},
"etag": "zHib8eXEMCxe4ayQEbIaZg=="
},
{
"name": "projects/12345678/locations/global/keys/a4db08b7-5729-4ba9-8c08-f2df493465a1",
"displayName": "API key 1",
"createTime": "2019-05-29T22:06:58.844Z",
"uid": "a4db08b7-5729-4ba9-8c08-f2df493465a1",
"updateTime": "2019-05-29T22:06:58.855103Z",
"restrictions": {
"androidKeyRestrictions": {}
},
"etag": "0L5KcPMGoNi53K5+FqPxiw=="
}
]
}By default, the ListKeys method returns a list of the usable API keys.
To view the list of all keys, including keys that are marked for deletion, add
the query parameter show_deleted=true:
curl -X GET