2016-08-30 65 views
0

有人可以幫助與後端的linkedIn集成。 這裏是麻煩,我有oauth_token(它已經與linkedIn javascript api響應),並且我想在後端使用該令牌。LinkedIn與抄寫員的集成

這裏是例子:

OAuth20Service service = new ServiceBuilder() 
     .apiKey(getLinkedInClientId()) 
     .scope("r_basicprofile r_emailaddress") // replace with desired scope 
     .apiSecret(getLinkedInSecret()) 
     .build(LinkedInApi20.instance()); 

    try { 
     OAuth2AccessToken accessToken = new OAuth2AccessToken(props.getToken(), "Bearer", 0, null, null, null); 

     final OAuthRequest request = new OAuthRequest(Verb.GET, String.format("https://api.linkedin.com/v1/people/~"), 
      service); 
     request.addHeader("x-li-format", "json"); 
     request.addHeader("Accept-Language", "ru-RU"); 
     service.signRequest(accessToken, request); 
     final Response response = request.send(); 
     String body = response.getBody(); 
     response.getMessage(); 

    } catch (Exception e) { 
     e.printStackTrace(); 
    } 

它總是說,我有無效的標記。

{ 
    "errorCode": 0, 
    "message": "Invalid access token.", 
    "requestId": "OKZVL3STZK", 
    "status": 401, 
    "timestamp": 1472554177625 
} 

此外,我試圖用阿帕奇oltu客戶沒有運氣(

好像我沒有得到有效的標記,因爲當我使用https://apigee.com/console/linkedin一切都很好

回答

0

我用了令牌它WASN 't access_token,所以我選擇使用OAuth2來實現後端。