Bootstrap FreeKB - Kong Community Edition (KongCE) - get Consumers API Key using REST API
Kong Community Edition (KongCE) - get Consumers API Key using REST API


The curl GET command can be used to list a Consumers API Key.


On the Kong server

If Kong is running on docker, refer to Kong - Docker container command line for the steps on how to issue commands in the Kong Docker container. Assuming you are using the default kong.conf file, the Kong Admin API will listen on port 8001.

If issuing this command on the Kong server, this command will display a Consumer API keys.

curl -X GET "http://localhost:8001/consumers/consumer_name_or_id/key-auth"

 


From a remote server

If issuing this command from a remote server, this command will display a Consumer API keys.

curl -X GET "http://hostname:8000/admin-api/consumers/consumer_name_or_id/key-auth"

 


Validation

If there are no API Keys associated with the Consumer, something like this will be displayed.

{
 "message":"Not Found"
}

 

If there is an API Key associated with the Consumer, something like this will be displayed. In this example, the API Key is "abc123".

{
 "next":null,
 "data":[
         {
          "created_at":1585018492,
          "consumer":{
                      "id":"6b3f8801-a8a2-4e48-ab54-53bdb285c334"
                     },
          "id":"7fac58ad-73ac-4dd3-a1f4-513711764d26",
          "tags":null,
          "ttl":null,
          "key":"abc123"
          }
        ]
}

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter bbb246 in the box below so that we can be sure you are a human.