I'm using Oltu for Oauth2.
When using @Context HttpServletRequest request I am unable to retrieve post data
When I am using @FormParam I am able to retrieve post data.
On passing request to OAuthTokenRequest
OAuthTokenRequest oauthRequest = new OAuthTokenRequest(request);
I am getting following error
{"error":"invalid_request","error_description":"Missing grant_type parameter value"}
When debugging on the oltu OAuthTokenRequest class following code is used to retrive param value
public String getParam(String name) {
return this.request.getParameter(name); // from request it is unable to get post data.As i am getting request object using @Context HttpServletRequest request .
}
It is said that using @Context HttpServletRequest request it is not possible to get post data for using @Context HttpServletRequest request So, my question is
How to get HttpServletRequest request with post data in jax-ws so that I can pass HttpServletRequest request to OAuthTokenRequest This is my code
@Path("/token")
public class TokenEndpoint {
@POST
@Consumes("application/x-www-form-urlencoded")
@Produces("application/json")
public Response authorize(@FormParam("state") String state,@Context HttpServletRequest request) throws OAuthSystemException {
try {
// here I am unable to get value of request.getParameter("state")
// but using (@FormParam("state") I am able to get value of post parameter state
request.getParameter("state");
// exception is thrown from following code
OAuthTokenRequest oauthRequest = new OAuthTokenRequest(request);