Not able get Oauth2 Access Token

I just started working Kong, I am trying to add oauth2 for my service.
I have followed the steps in Doc.
When I request for access token, I am getting bellow error.
{“message”:“no route and no API found with those values”}

Am I Missing anything. Please help me to address the issue

Service Reg:

curl -X POST http://:8001/services/
–data “name=service1”
–data “url=http:///”

Route Creation:

curl -i -X POST
–url http://:8001/services/service1/routes
–data ‘hosts[]=’
–data ‘paths[]=/v1/api/orders’
–data ‘methods[]=GET’

Adding Plugin for service1:

curl -X POST http://:8001/services/service1/plugins
–data “name=oauth2”
–data “config.scopes=read”
–data “config.mandatory_scope=true”
–data “config.token_expiration=7200”
–data “config.enable_client_credentials=true”
–data “config.global_credentials=true”

Consumer Reg:
curl -X POST http://<Kong IP>:8001/consumers --data "" --data "custom_id=1032"

Binding Consumer:

curl -X POST http://<Kong IP>:8001/consumers/ \
--data "name=clientapp1" \
--data "client_id=TEST_CLIENT" \
--data "client_secret=TEST_SECRET" \
--data "redirect_uri=http:/<Service IP>//" 

Access Token Request:	

curl -X POST -k https://localhost:8443/v1/api/orders/oauth2/token/ \
--data "client_id=TEST_CLIENT" \
--data "client_secret=TEST_SECRET" \
--data "grant_type=client_credentials" \
--data "provision_key=vVvHL0V8qTlyzGNlZqJ7M8oUW5rVKpIG" \
--data "" \
--data "scope=read"

Hi Thamaiyanthi,

It is not very clear how your system set up but I did a quick test and it works as expected.

curl -X POST \
  --url "https://localhost:8443/v1/api/orders/oauth2/token" \
  --data "grant_type=client_credentials" \
  --data "scope=read" \
  --data "client_id=TEST_CLIENT" \
  --data "client_secret=TEST_SECRET" \
  --data "provision_key=cqOqFIZBqsFuqllA5HXxONb5gy5Nfw0e" \
  --data "" \


Maybe you can follow the tutorial here How to use Kong Oauth2 Plugin and see if it helps you.


Thanks a lot for your reply. As per you suggestion,
I referred this blog “How to use Kong Oauth2 Plugin” and followed the steps. Now I am able to get token.

© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ