Unauthorized client in client-credential

Hi,

I am using Tyk to create a simple client-credential test. The Tyk gateway version is v4.0.0.

Basically I want to proxy through httpbin using this client-credential authentication method. In the API definition, I used:

“oauth_meta”:{
“allowed_access_types”:[
“client_credentials”
],
“allowed_authorize_types”:[
“code”,
“token”
],
“auth_login_redirect”:“”
}

I created the oauth client through this API endpoint: https://{tyk-endpoint}/tyk/oauth/clients/create, with the request body which includes api_id, and policy_id. And I got this response back (status 200):

{
“client_id”: “a7dd557656224a75abb80a5674238c92”,
“redirect_uri”: “”,
“policy_id”: “62babe1a442cbe0001b6b94e”,
“secret”: “OGRkNTAwOTktZGNhMy00ZTY2LWFjZGEtZWM0ZTNiOTI5YWEz”,
“meta_data”: null,
“description”: “”
}

Now, I tried to get the token for this API using this API endpoint:

curl -X POST
http://{tyk-endpoint}/{api-listen-path}/oauth/token/
-H ‘Authorization: Basic xxx’
-H ‘Content-Type: application/x-www-form-urlencoded’
-d ‘client_id=xxx&client_secret=yyy&grant_type=client_credentials’

However, I got this response back:

{
“error”: “unauthorized_client”,
“error_description”: “The client is not authorized to request a token using this method.”
}

What is the reason for this error to happen? Is there any setting/ config I have to do?

Thanks.

Regards,

Maan Tarng

I see your redirect value is empty. It is important to add a redirect URL, even if it is just a dummy value. Try adding a redirect URL and test again.

Hi @Olu

Yes. When I put the redirect uri, it works.

Thanks for your help!

1 Like