Kong / docs.konghq.com

🦍 Source code for docs.konghq.com website.
https://docs.konghq.com
MIT License
193 stars 579 forks source link

To add to the documentation for OAuth 2.0 Authentication #4502

Open RagunathInGIT opened 1 year ago

RagunathInGIT commented 1 year ago

Where is the problem?

https://docs.konghq.com/hub/kong-inc/oauth2/

What happened?

I dont see documentation of various ways of calling "/oauth2/token" call for client_credentials flow.

What did you expect to happen?

In Client credentials flow, there is a provision to make "oauth2/token" call by passing the client ID, client secret and grant_type as query param or a JSON body along with usual way of sending it in URL-encoded way.

Code of Conduct and Community Expectations

RagunathInGIT commented 1 year ago

I would like to fix it and submit it for Hackathon 2022. Can you please let me know which repository I need to fork and create pull request?

RagunathInGIT commented 1 year ago

Current Documentation :

There are no examples under client credentials flow to the various ways of how we can call the "/oauth2/token" to get the access_token when Kong acts as an IDP.

https://docs.konghq.com/hub/kong-inc/oauth2/

Expected Documentation :

Below are the various ways we can consume "/oauth2/token" endpoint the retrieve the access_token.

  1. Content-Type set to application/x-www-form-urlencoded and sending the credentials as a form data in a POST call.

curl --location --request POST 'https://XXXX/v1/oauthprovider/oauth2/token' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'client_id=XXXX' \ --data-urlencode 'client_secret=XXXX' \ --data-urlencode 'grant_type=client_credentials'

  1. Content-Type set to application/json and sending the credentials as a JSON body in a POST call.

curl --location --request POST 'https://XXXX/v1/oauthprovider/oauth2/token' \ --header 'Content-Type: application/json' \ --data-raw '{ "client_id": "XXXXX", "client_secret": "XXXX", "grant_type": "client_credentials" }'

  1. Sending the credentials in URL query param in a POST call.

curl --location --request POST 'https://XXXX/v1/oauthprovider/oauth2/token?client_id=XXXX&client_secret=XXXX&grant_type=client_credentials'