Trying to follow the example in https://tyk.io/tyk-documentation/security/security-policies/full-policies/ to apply a policy configured in policies.json to a key but receives error
"Failed to create key, keys must have at least one Access Rights record set.".
Here’s the command sent to tyk gateway :
curl -X POST -H "x-tyk-authorization: 352d20ee67be67f6340b4c0605b044b7" \
-s \
-H "Content-Type: application/json" \
-X POST \
-d '{
"allowance": 1000,
"rate": 1000,
"per": 1,
"expires": -1,
"quota_max": -1,
"org_id": "1",
"quota_renews": 1449051461,
"quota_remaining": -1,
"quota_renewal_rate": 60,
"apply_policy_id": "default",
"meta_data": {}
}' http://localhost:8080/tyk/keys/create | python -mjson.tool
Kos
May 2, 2017, 8:19am
2
Hi sp_now,
The /tyk/keys/create
endpoint you are targeting is to create an API Key with the REST API .
You should follow the appropriate tutorial in our Get started section.
Let me know if you need any further assistance.
Thanks,
Kos @ Tyk Support Team
Hi Kos
apologies… think i figured out the solution.
The issue was due to the a different tyk.conf being picked up when running “service tyk-gateway start” and “./tyk”. Thefore the correct policies.json file was not picked up.
Thanks anyway
The policy loader currently doesn’t show policies that have been loaded (whereas if using the dashboard it does), this has been addressed in this ticket here:
opened 09:48PM - 29 Mar 17 UTC
closed 10:20AM - 12 Sep 17 UTC
enhancement
**Do you want to request a *feature* or report a *bug*?**
Feature
**What is … the current behavior?**
Policies are not listed when using file-based mode
**What is the expected behavior?**
The policy IDs should be listed out (like they are when the dashboard is used) as it makes it easier to confirm whether they have been activated.
**Which versions of Tyk affected by this issue? Did this work in previous versions of Tyk?**
All
So is expected to be fixed in 2.4