获取与linkedin的连接时出错

时间:2015-05-29 06:37:36

标签: java servlets linkedin-j

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub


    final LinkedInOAuthService oauthService = LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService(CONSUMER_KEY, CONSUMER_KEY_SECRET);


    try {
        StringBuffer callbackURL = request.getRequestURL();
        int index = callbackURL.lastIndexOf("/");
        callbackURL.replace(index, callbackURL.length(), "").append("/LinkedInCallbackServlet");


        LinkedInRequestToken requestToken = oauthService.getOAuthRequestToken(callbackURL.toString());
        request.getSession().setAttribute("requestToken", requestToken);
        System.out.println("token:"+requestToken);
        System.out.println("Success");

        String path=callbackURL.toString();
        String verifier = request.getParameter("oauth_verifier");
        System.out.println("----"+verifier);

        response.sendRedirect(requestToken.getAuthorizationUrl());

    } catch (LinkedInApiClientException e) {
        throw new ServletException(e);
    }
}


/**  * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stubss
}

运行此代码时会显示错误:

  

HTTP状态500 - oauth.signpost.exception.OAuthCommunicationException:与服务提供商的通信失败:服务器返回HTTP响应代码:403为URL:https://api.linkedin.com/uas/oauth/requestToken

0 个答案:

没有答案
相关问题