Hello, i am studying tyk for commercial use and i am stuck. I have followed the following steps and I still have this “error”: “Authorization field missing” error. did I miss something?
Steps
1.Configure a network
docker network create tyk
2.Redis Dependency
docker pull redis:4.0-alpine
docker run -itd --rm --name redis --network tyk -p 127.0.0.1:6379:6379 redis:4.0-alpine
3. Deploy Tyk Gateway
docker pull tykio/tyk-gateway:latest
4. Run Tyk Gateway
docker run -d --name tyk_gateway --network tyk -p 8080:8080 -v C:/tyk-gateway/conf/tyk.standalone.conf:/opt/tyk-gateway/tyk.conf -v C:/tyk-gateway/apps:/opt/tyk-gateway/apps tykio/tyk-gateway:latest
Files contents
app_sample.json
{
“name”: “Tyk Secured Employee API”,
“api_id”: “1”,
“org_id”: “default”,
“definition”: {
“location”: “”,
“key”: “”
},
“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”: “/secured/rh_api”,
“target_url”: “http://192.168.1.23:8090/demo”,
“strip_listen_path”: true
},
“enable_batch_request_support”: true
}
tyk.standalone.conf
{
“listen_port”: 8080,
“secret”: “352d20ee67be67f6340b4c0605b044b7”,
“template_path”: “/opt/tyk-gateway/templates”,
“tyk_js_path”: “/opt/tyk-gateway/js/tyk.js”,
“middleware_path”: “/opt/tyk-gateway/middleware”,
“use_db_app_configs”: false,
“app_path”: “/opt/tyk-gateway/apps/”,
“storage”: {
“type”: “redis”,
“host”: “redis”,
“port”: 6379,
“username”: “”,
“password”: “”,
“database”: 0,
“optimisation_max_idle”: 2000,
“optimisation_max_active”: 4000
},
“enable_analytics”: false,
“analytics_config”: {
“type”: “csv”,
“csv_dir”: “/tmp”,
“mongo_url”: “”,
“mongo_db_name”: “”,
“mongo_collection”: “”,
“purge_delay”: -1,
“ignored_ips”: []
},
“health_check”: {
“enable_health_checks”: true,
“health_check_value_timeouts”: 60
},
“optimisations_use_async_session_write”: true,
“enable_non_transactional_rate_limiter”: true,
“enable_sentinel_rate_limiter”: false,
“enable_redis_rolling_limiter”: false,
“allow_master_keys”: false,
“policies”: {
“policy_source”: “file”,
“policy_record_name”: “/opt/tyk-gateway/policies/policies.json”
},
“hash_keys”: true,
“close_connections”: false,
“http_server_options”: {
“enable_websockets”: true
},
“allow_insecure_configs”: true,
“coprocess_options”: {
“enable_coprocess”: true,
“coprocess_grpc_server”: “”
},
“enable_bundle_downloader”: true,
“bundle_base_url”: “”,
“global_session_lifetime”: 100,
“force_global_session_lifetime”: false,
“max_idle_connections_per_host”: 500
}
**5. Result **
Test1
curl http://localhost:8080/secured/rh_api/employees -H 'authorization: 352d20ee67be67f6340b4c0605b044b7' -v
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET /secured/rh_api/employees HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.55.1
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Content-Type: application/json
< X-Generator: tyk.io
< Date: Fri, 16 Oct 2020 00:03:34 GMT
< Content-Length: 46
<
{
"error": "Authorization field missing"
}* Connection #0 to host localhost left intact
* Rebuilt URL to: 352d20ee67be67f6340b4c0605b044b7'/
* Could not resolve host: 352d20ee67be67f6340b4c0605b044b7'
* Closing connection 1
curl: (6) Could not resolve host: 352d20ee67be67f6340b4c0605b044b7'
Test2
curl http://localhost:8080/secured/rh_api/employees -H 'x-tyk-authorization: 352d20ee67be67f6340b4c0605b044b7' -v
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET /secured/rh_api/employees HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.55.1
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Content-Type: application/json
< X-Generator: tyk.io
< Date: Fri, 16 Oct 2020 00:03:09 GMT
< Content-Length: 46
<
{
"error": "Authorization field missing"
}* Connection #0 to host localhost left intact
* Rebuilt URL to: 352d20ee67be67f6340b4c0605b044b7'/
* Could not resolve host: 352d20ee67be67f6340b4c0605b044b7'
* Closing connection 1
curl: (6) Could not resolve host: 352d20ee67be67f6340b4c0605b044b7'