Skip to content

Instantly share code, notes, and snippets.

@matiasinsaurralde
Last active May 18, 2018 11:00
Show Gist options
  • Save matiasinsaurralde/55e733a7a193c8a92a08a095226fa885 to your computer and use it in GitHub Desktop.
Save matiasinsaurralde/55e733a7a193c8a92a08a095226fa885 to your computer and use it in GitHub Desktop.
Tyk - Existing tokens

These instructions assume you have an API with the settings specified in quickstart.json (see below).

To add this token, save the JSON contents as token.json, then:

curl http://127.0.0.1:8080/tyk/keys/abc -H 'x-tyk-authorization: 352d20ee67be67f6340b4c0605b044b7' -H 'Content-Type: application/json'  -d @token.json

Where abc, in the URL, is your existing key.

x-tyk-authorization is the Tyk gateway secret, found in tyk.conf.

After this steps, the following request will fail (the key doesn't exist):

curl http://127.0.0.1:8080/quickstart/headers -H 'Authorization: invalid123'

And if you use your new key:

curl http://127.0.0.1:8080/quickstart/headers -H 'Authorization: abc'
{
"name": "Tyk Test API",
"api_id": "3",
"org_id": "default",
"definition": {
"location": "",
"key": ""
},
"use_keyless": false,
"auth": {
"auth_header_name": "Authorization"
},
"version_data": {
"not_versioned": true,
"versions": {
"Default": {
"name": "Default",
"expires": "3000-01-02 15:04",
"use_extended_paths": true,
"extended_paths": {
"ignored": [],
"white_list": [],
"black_list": []
}
}
}
},
"proxy": {
"listen_path": "/quickstart/",
"target_url": "http://httpbin.org/",
"strip_listen_path": true
}
}
{
"allowance": 1000,
"rate": 1000,
"per": 60,
"expires": -1,
"quota_max": -1,
"quota_renews": 1406121006,
"quota_remaining": 0,
"quota_renewal_rate": 60,
"access_rights": {
"3": {
"api_name": "Tyk Test API",
"api_id": "3"
}
},
"org_id": "53ac07777cbb8c2d53000002",
"basic_auth_data": {
"password": "",
"hash_type": ""
},
"hmac_enabled": false,
"hmac_string": "",
"is_inactive": false,
"apply_policy_id": "",
"monitor": {
"trigger_limits": []
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment