I want to obtain an Access Token is for my application using the Authorization Code it just acquired. I am using this code
DefaultHttpClient client = new DefaultHttpClient();
URI uri = new URIBuilder().setScheme("https")
.setHost("www.linkedin.com")
.setPath("/uas/oauth2/accessToken")
.setParameter("grant_type", "authorization_code")
.setParameter("code", code)
.setParameter("redirect_uri", "http://localhost:9090/ConnectSocialMedia/callBack.jsp")
.setParameter("client_id", CONSUMER_KEY_OPTION)
.setParameter("client_secret", CONSUMER_SECRET_OPTION)
.build();
HttpPost post = new HttpPost(uri);
post.setHeader("Content-Type", "application/x-www-form-urlencoded");
HttpResponse response2 = client.execute(post);
System.out.println("Final Response------------>"+response2);
But I am getting HTTP/1.1 400 Bad Request. What am I doing wrong?
Any help would be really appreciated!