Bad request Error when requesting an access token inside Oauth2 Plugin

141 views
Skip to first unread message

vaibhav thapliyal

unread,
Feb 9, 2017, 6:17:08 AM2/9/17
to Kong
Dear All,

I am trying to enable OAuth2 using Kong. I am using this project as a starting point. I am able to proceed till the point where I have to get the "code" parameter and the redirect uri.

But when I issue the POST request to get the access from the "code" I get the following response:

<html>
<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<center>The plain HTTP request was sent to HTTPS port</center>
<hr><center>openresty/1.11.2.1</center>
</body>
</html>

The Request that I send is:

curl -X POST http://localhost:8443/oauth2/token \
     
-H "Host: test.com" \
     
-d "grant_type=authorization_code" \
     
-d "client_id=b0d67fbce15c411cad85bb9b764b534a" \
     
-d "client_secret=e2e9ba5e38444affb8398ca2014ca869" \
     
-d "redirect_uri=http://getkong.org/" \
     
-d "code=ea64b6a5958e423f8e98592eaf48ab7c" --insecure

I checked online for this issue and it seems to indicate this might be due to some ill-configured conf file. I am also attaching that. I am currently using 0.9.8 version of Kong and Ubuntu 14.04.

Please Help.

Thanks
Vaibhav



kong.conf

Thibault Charbonnier

unread,
Feb 9, 2017, 1:56:14 PM2/9/17
to kong...@googlegroups.com
Hi,

I think the error message is clear enough: you sent a plain HTTP request to the HTTPs port of Kong (its default one is 8443. You should send that request over HTTPs instead.

Give it a try and let us know.

Best,
Thibault
--
You received this message because you are subscribed to the Google Groups "Kong" group.
To unsubscribe from this group and stop receiving emails from it, send an email to konglayer+...@googlegroups.com.
To post to this group, send email to kong...@googlegroups.com.
Visit this group at https://groups.google.com/group/konglayer.
To view this discussion on the web visit https://groups.google.com/d/msgid/konglayer/01d45b69-febd-44de-b8ae-3bd2cd024d0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

vaibhav thapliyal

unread,
Feb 13, 2017, 12:49:31 AM2/13/17
to Kong, thiba...@fastmail.com
Yes I was able to get this working. I am attaching a file which has the curl commands to get this running in case it helps someone.
Thanks for the help.
KongExampleCommands.txt
Reply all
Reply to author
Forward
0 new messages