Hi,
I am trying to use Tyk Open Source Gateway to learn client-credential work flow. I am referring to this website: Tyk Management API: OAuth2 Application Flow (client_credntials grant type) - DZone
I managed to follow some of the steps there. However, I am quite confused about the step on retrieving the client-credential token. Because when I refer to Tyk documentation (Tyk Gateway API ), it looks like there is no url to retrieve the token (under the OAUTH section).
May I know how to retrieve the token? Is there any url path to call to get the token? Is there any example on this client-credential using Tyk open-source gateway?
Thanks.
Olu
May 17, 2022, 1:31pm
2
Hi @maantarng , I think the URL you are looking for based on the link shared is
{{gateway-endpoint}}
/{{api-listen-path}}
/oauth/token/
If you have successfully created you OAuth client, then the client_secret
and client_id
can be retrieved from there.
Hope this helps
Hi @Olu , Thanks.
I have created the Oauth client, and get my client_id and client_secret.
Here, I use the url path you suggested:
curl -X POST
http://localhost:8080/oauth-test-api/oauth/token/
-H ‘x-tyk-authorization:foo’
-H ‘Authorization: Basic xxx’
-H ‘Content-Type: application/x-www-form-urlencoded’
-d ‘client_id=xxxx&client_secret=xxx&grant_type=client-credentials’
However, when I hit this url, I saw an error message saying ‘the authorization grant type is not supported by the authorization server ’.
Do you know why this is happening? Anything I missed in the url?
Olu
May 18, 2022, 10:58am
4
I guess it’s because you have an hyphen/dash as the separator in client credentials instead of an underscore.
Hi @Olu I changed it. But I still get the same error response. Do you know why this is happening?
Olu
May 19, 2022, 8:34am
6
There could be a mis-match for the 0auth2 grant type in your API definition. It should be set to client credentials as shown below
...
"oauth_meta": {
"allowed_access_types": [
"client_credentials"
],
"allowed_authorize_types": [
"code"
],
"auth_login_redirect": "<redirect-url>"
},
"use_oauth2": true,
...