I have a problem with wso2 identity server that could be a concept error, but I don't really understand what I am doing wrong.
I have a JAVA REST aplication that needs to validate the user with an oauth2 Identification Server. I have installed wso2 Identity Server 5.0.0 on a debian box. I created the end users and created the service provider to obtain the clientid and client secret.
The process I am following is this:
My APP usees the following java code to send the requests:
URL url = new URL(desturl);
HttpsURLConnection huc = (HttpsURLConnection) url.openConnection();
huc.setRequestMethod("POST");
huc.connect();
huc.setConnectTimeout(10000);
rd = new BufferedReader(new InputStreamReader(huc.getInputStream()));
String line;
while ((line = rd.readLine()) != null) {
content += line;
}
My app sends the following http request as a POST:
https://<wso2is>:9443/oauth2/authorize?response_type=code&client_id=<xxx>&state=xyz&redirect_uri=http://<tomcat>:8080/myapp/rest/listener
IS asks the user to login and generates the following request to my app:
http://<wso2is>:8080/myapp/rest/listener?state=xyz&code=<xxx>
In this step, and with the user logged in my app asks for the user info:
https://<wso2is>:9443/oauth2/token?grant_type=authorization_code&code=<xxx>&redirect_uri=http://<wso2is>:8080/myapp/rest/listener&client_id=<xxx>&client_secret=<xxx>
Here I get a HTTP 415 response code. This is a format error andin some place I have read that I am suposed to change the Content-Type of the request. I have tried json and xml but didn't work.
I have had this same app working with another IdM that was supposed to be standard (Fiware KeyRock Idm). Does anybody know what I am doing wrong?
-- UPDATE --
I have found that adding to the code the following:
huc.setRequestProperty("Content-Type", "application/octet-stream");
Gives a different error in the IS sytem logs:
No operation matching request path "/oauth2/token" is found
But still the same error on the APP side.
Finally I have changed the way of doing it. Instead of coding the HTTP client by hand I have used Apache OLTU. Much easier this way and it works.
This link[1] will provide necessary request format you want to send. According to your problem content-type should be "application/x-www-form-urlencoded"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.