0
查看https://developer.linkedin.com/docs/oauth2我試着在這裏獲取訪問令牌。HTTP響應代碼:411 for Apache with ApacheOltu
這段代碼有什麼問題?
OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());
TokenRequestBuilder r = OAuthClientRequest
.tokenLocation("https://www.linkedin.com/oauth/v2/accessToken")
.setCode(code)
.setGrantType(GrantType.AUTHORIZATION_CODE)
.setClientId(LinkedInClientID)
.setClientSecret(LinkedInClientSecret)
.setRedirectURI("http://localhost:8080/authenticatedLinkedIn");
Map<String,String> m = new HashMap<String,String>();
m.put("Content-Type", "application/x-www-form-urlencoded");
int bodyLength = r.buildBodyMessage().getBody().length();
System.out.println("Body l = " + bodyLength);
m.put("Content-Length", Integer.toString(bodyLength));
r.buildHeaderMessage().setHeaders(m);
OAuthClientRequest request = r.buildQueryMessage();
OAuthJSONAccessTokenResponse tk = oAuthClient.accessToken(request, OAuth.HttpMethod.POST);
我收到以下錯誤: