# Not able get Oauth2 Access Token

**URL:** <https://discuss.konghq.com/t/not-able-get-oauth2-access-token/8680>\
**Category:** General\
**Created:** [July 9, 2021, 7:42pm UTC](https://discuss.konghq.com/t/not-able-get-oauth2-access-token/8680 "2021-07-09T19:42:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thamaiyanthi](https://avatars.discourse-cdn.com/v4/letter/t/48db29/32.png) [@Thamaiyanthi](https://discuss.konghq.com/u/Thamaiyanthi)\
**Post date:** [July 9, 2021, 7:42pm UTC](https://discuss.konghq.com/t/not-able-get-oauth2-access-token/8680/1 "2021-07-09T19:42:35Z")

</div>

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 "username=test@gmail.com" --data "custom_id=1032"

Binding Consumer:

curl -X POST http://<Kong IP>:8001/consumers/test@gmail.com/oauth2 \
--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 "authenticated_userid=test@gmail.com" \
--data "scope=read"

```

---

<div class="post-metadata">

**Author:** ![fomm](https://avatars.discourse-cdn.com/v4/letter/f/ea666f/32.png) [@fomm](https://discuss.konghq.com/u/fomm)\
**Post date:** [July 10, 2021, 10:49am UTC](https://discuss.konghq.com/t/not-able-get-oauth2-access-token/8680/2 "2021-07-10T10:49:08Z")

</div>

> [@Thamaiyanthi](#):
>
> `TEST_SECRET`

Hi Thamaiyanthi,

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

```auto
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 "authenticated_userid=test@gmail.com" \
  --insecure

{"token_type":"bearer","access_token":"xvpEJp9AjDKltYjkk5JXsm1JaFc6nUMb","expires_in":7200}

```

Maybe you can follow the tutorial here [https://tech.aufomm.com/How-to-use-Kong-Oauth2-Plugin](https://tech.aufomm.com/How-to-use-Kong-Oauth2-Plugin) and see if it helps you.

---

<div class="post-metadata">

**Author:** ![Thamaiyanthi](https://avatars.discourse-cdn.com/v4/letter/t/48db29/32.png) [@Thamaiyanthi](https://discuss.konghq.com/u/Thamaiyanthi)\
**Post date:** [July 10, 2021, 6:30pm UTC](https://discuss.konghq.com/t/not-able-get-oauth2-access-token/8680/3 "2021-07-10T18:30:53Z")

</div>

Hi,

Thanks a lot for your reply. As per you suggestion,  
I referred this blog “[How to use Kong Oauth2 Plugin](https://tech.aufomm.com/How-to-use-Kong-Oauth2-Plugin)” and followed the steps. Now I am able to get token.
