如何在OAuth调用中解决请求令牌的400错误

时间:2015-05-18 08:49:21

标签: java oauth linkedin

我想使用它刚刚获得的OAUth代码为我的应用程序获取访问令牌。这是我到目前为止所做的代码

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);

但每次我每次都收到HTTP / 1.1 400 Bad Request。任何人都可以帮助我做错了。谢谢提前

0 个答案:

没有答案