Dashboard API - Get a list of Keys not work


#1

I setup the standalone deployment of Tyk (include tyk_gateway and tyk_dashboard), after I generated a API Key (API Token) on the dashboard UI, then tried to get the keys via the API:

`
GET /api/apis/9662dec53b3d4d3d7ea6dc0bbeeb4959/keys/ HTTP/1.1
Host: dashboard.tyk.test.dsd:3000
Authorization: 18b53b4c5a3f401c4321f6dbc963ce35

HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 05 Jul 2016 11:23:22 GMT
Content-Length: 32

{“data”:{“keys”:null},“pages”:0}
`

The result is null.

But if I get the key with the key id:
`
GET /api/apis/9662dec53b3d4d3d7ea6dc0bbeeb4959/keys/577b8b09c793170001000001c55ad4c33db94d2f6896c48fcc85f161 HTTP/1.1
Host: dashboard.tyk.test.dsd:3000
Authorization: 18b53b4c5a3f401c4321f6dbc963ce35

HTTP/1.1 200 OK
Content-Type: application/json
Date: Tue, 05 Jul 2016 11:30:08 GMT
Content-Length: 718

{“api_model”:{},“key_id”:“577b8b09c793170001000001c55ad4c33db94d2f6896c48fcc85f161”,“data”:{“last_check”:0,“allowance”:998,“rate”:1000,“per”:1,“expires”:0,“quota_max”:-1,“quota_renews”:1467717279,“quota_remaining”:-1,“quota_renewal_rate”:60,…}}
`

It works.

From the document https://tyk.io/docs/tyk-dashboard-v1-0/dashboard-api/api-tokens/, has a api for get list of keys.

Any operations I did wrong?

Thanks!


#2

Hi, it’s not possible to list API keys when you’re using hashed keys, the documentation has a note about this:

Note: This will not work with a hashed key set.

You may also read “Token Lifecycle”:

Since keys in Tyk are hashed, you may also not have direct access to the original token in order to manually change the policy for that token. Also, if you manually upgrade a policy on a key, it may not reflect in their developer profile, which is the core part of the service that identifies a developer to your organization.

If you’re expecting to “list” keys you should disable hashing.


#3

Oh, thanks very much.

So, I just need to change the tyk.conf and tyk_analytics.conf with “hash_keys”: false, then restart the both services?
Do not need other configuration yet?

Thanks!


#4

Yes, you’ll probably need to generate new keys after restarting. And you should be able to list them.


#5

Thank you again, I will do it and see result.