Tyk Gateway OAuth Key not authorised

I am currently working on Tyk Gateway CE. I’ve installed it using tyk-oss-k8s-deployment. Using OAuth 2.0 as reference:

  1. I’ve created an API which should use OAuth for authentication:
    {
    “name”: “oauth-test-api”,
    “slug”: “oauth-test-api”,
    “api_id”: “oauth-test-api”,
    “org_id”: “1”,
    “use_oauth2”: true,
    “oauth_meta”: {
    “allowed_access_types”: [“client_credentials”],
    “allowed_authorize_types”: [“token”],
    “auth_login_redirect”: “http://httpbin.org/
    },
    “definition”: {
    “location”: “header”,
    “key”: “x-api-version”
    },
    “version_data”: {
    “not_versioned”: true,
    “versions”: {
    “Default”: {
    “name”: “Default”,
    “use_extended_paths”: true
    }
    }
    },
    “proxy”: {
    “listen_path”: “/oauth-test-api/”,
    “target_url”: “http://httpbin.org/”,
    “strip_listen_path”: true
    },
    “active”: true
    }

  2. I’ve created a persistent volume and persistent volume claim where I can update policies.json. Currently policies.json contains the following:

    {
    “oauth_test_policy”: {
    “access_rights”: {
    “oauth-test-api”: {
    “allowed_urls”: [],
    “api_id”: “oauth-test-api”,
    “api_name”: “oauth-test-api”,
    “versions”: [
    “Default”
    ]
    }
    },
    “active”: true,
    “name”: “OAuth Test Policy”,
    “rate”: 100,
    “per”: 1,
    “quota_max”: 10000,
    “quota_renewal_rate”: 3600,
    “tags”: [“Test Policy”]
    }
    }

  3. Then, I hit /oauth-test-api/oauth/token to retrieve the token

  4. Once I got the token, I added it as bearer for my API call.


    However, I’m receiving this error:
    {
    “error”: “Key not authorised”
    }

Can you please tell me if I missed or misconfigured anything ?

Thanks in advance.

Managed to get this working by adding org_id in the policy. However, now I’m getting another issue:
{
“error”: “There was a problem proxying the request”
}

time=“Mar 01 22:23:36” level=error msg=“http: proxy error: dial tcp: lookup httpbin.org: Temporary failure in name resolution” api_id=oauth-test-api api_name=oauth-test-api mw=ReverseProxy org_id=sku prefix=proxy server_name=httpbin.org user_id="****8289" user_ip=172.17.0.1 user_name=

1 Like

All working now after changing to https://httpbin.org

1 Like

@mcabrera were you following the documentation on our website? If so, was it missing information?

looks like it was the schema @zaid

Hi @zaid . Yes, I was following the documentation mentioned in my initial post. I think it would help a lot if we can see documentation of each field and how it relates to each component. Thanks!

@mcabrera you’re absolutely right. We are currently working on improving our documentation and this feedback is much appreciated. And just as an FYI you can always help and contribute to the docs yourself on our GitHub repository GitHub - TykTechnologies/tyk-docs

1 Like