Kong: OAuth2.0 how can I get the token?

Created on 15 Aug 2016  ·  26Comments  ·  Source: Kong/kong

I'm doing with https://getkong.org/plugins/oauth2-authentication step by step.

POST to http://localhost:8001/oauth2/token I can't get the token and the response is 404.

My body params :

client_id:xxx
scope:xxx
client_secret:xxx
provision_key:xxx
authenticate_userid:xxx
pluginoauth2

All 26 comments

You must use https

Is not Admin API?

https use 8443 port

Could not get any response after POST https://localhost:8001/oauth2/token

If I visited https://localhost:8443/{api}/oauth2/token

Response output:

{
  "error": "unsupported_grant_type",
  "error_description": "Invalid grant_type"
}

Indeed you have to use the 8443 (configurable port). What is the grant_type you use at the moment?

If you have for example authorization grant, then you can do:
authorization grant example

what is the code? how can I get it?

for authorization grant this is the authorization code (which you have to pickup first, before calling /token endpoint):
auth grant authorize

Can not get token still...

Is there anything wrong?

1 pic
2 pic
3 pic

did you create oauth2 credentials for your consumer?
try: http://localhost:8001/consumers/{consumer_id}/oauth2 on your consumer to verify if oauth2 client_id and client_password exists, including callback uri

4 pic

Can you try sending as form url-encoded in your REST client ? Seems ok to me

I found your POST Headers contain Authorization: xxxxx , what it is?

I'm using paw like you :

6 pic_hd

Using Kong 0.8.3, I run through all steps just in case, using postman now :-):
API:
schermafdruk 2016-08-15 15 58 02

An a consumer:
schermafdruk 2016-08-15 15 58 07

Verify OAuth2:
schermafdruk 2016-08-15 15 58 13

And as well for consumer:
schermafdruk 2016-08-15 15 58 17

Get the authorization code:
schermafdruk 2016-08-15 15 58 25

And that should work.

You need to request the token on the proxy port 8000, while still including the right request_path or request_host to help Kong identify the API.

I do all step once again but the same problem appeared.

I GET http://localhost:8001/consumers/7e84c1cc-7d7a-40dd-86b8-6ef935304d31/oauth2

{
      "consumer_id": "7e84c1cc-7d7a-40dd-86b8-6ef935304d31",
      "client_id": "clientid002",
      "id": "bd71012e-4b66-4254-b877-a8748dc8eb41",
      "created_at": 1471310810000,
      "name": "appname2",
      "redirect_uri": "[\"http:\\/\\/www.baidu.com\"]",
      "client_secret": "clientsecret002"
    }

The redirect_uri contain escape character but you have not.

How do you added the redirect_uri?

Is this about database? I'm using postgresql.

There is a problem with Postgresql really.

I use the cassandra ,everything is OK.

I think there is a bug with use postgresql...

@seedotlee what version of Kong are you using? Can you try with latest 0.9 ?

@thefosk v0.8.3

@seedotlee I reccomend upgrading to 0.9 - I think this bug has been fixed there.

@thefosk OK, thanks!

I am unable to get authorization_token

screen shot 2019-02-06 at 11 28 39 pm

need help in resolving the issue

I am unable to get authorization_token

screen shot 2019-02-06 at 11 28 39 pm

need help in resolving the issue

Are you able to resolve this? I am getting the same error!

https://localhost:8443/oauth2/token 404 with {"message": "no Route matched with those values"}

I am getting the same error! Need Help! @subnetmarco

I am getting the same error https://github.com/Kong/kong/issues/1500#issuecomment-549107330 too :(

Getting same error here. Has anyone fixed it?

Was this page helpful?
0 / 5 - 0 ratings