I am using kong 0.14 with Postgres 9.6. After creating consumer, application, service, plugin and routes I tried to fetch oauth token but I am unable to get oauth2/token for client_credentials flow.
My request is as below
curl --insecure https://localhost:8443/oauth2/token -d “client_id=tFn3WQ278RPpulDW&grant_type=client_credentials&client_secret=V0271fN5vvl117vKViJVcgw”
I tried the same setup using Cassandra and it worked. Am I missing anything for Postgres ?
Thanks for tips. It worked. Kong integration with Cassandra didn’t complain about this. I only faced this issue when I tried to do setup Kong using Postgres.
I am facing similar problem but my code is in scala. here is what I am doing. However when I try in POSTMAN it work absolutely fine. Can you see what I am doing wrong ?
case class credentials (
scope: String, //="/consent.create /consent.read /library.read"
grant_type: String //=“client_credentials”
)
val id="<kEY>"
val secret="<SECRET>"
val authString = Base64.getEncoder.encodeToString(s"$id:$secret".getBytes(StandardCharsets.UTF_8))
val cred = new credentials("/consent.create /consent.read /library.read", “client_credentials”)
val body = new Gson().toJson("1:3")
//val body = gson.toJson(cred)
val endpoint = "https://<HOSTNAME>/api/v1/oauth/v1/token"
val url = endpoint //+ "&client_id=" + + "&client_secret=" + _clientSecret
println(url)
val client = HttpClientBuilder.create().build()
val post = new HttpPost(url)
post.addHeader("Content-Type", "application/x-www-form-urlencoded")
post.addHeader("Authorization", "Basic " + authString)
post.addHeader("grant_type", "client_credentials")
post.addHeader("scope", "<HOSTNAME>/consent.create <HOSTNAME>/consent.read <HOSTNAME>/library.read")
post.setEntity(new StringEntity(body))
println(post.getAllHeaders.foreach(println))
val response = client.execute(post)
println("response:" + response)
sorry for the late reply. Are you still getting error?
In my case I added a route with path “/oauth2/token” and set this as global level.
Please check.