Ejemplo n.º 1
0
 public OAuthToken getRequestToken(String clientId, String clientSecret) {
   OAuthService service =
       new ServiceBuilder()
           .provider(LinkedInApi.class)
           .apiKey(clientId)
           .apiSecret(clientSecret)
           .build();
   Token requestToken = service.getRequestToken();
   OAuthToken result = new OAuthToken();
   result.setToken(requestToken.getToken());
   result.setTokenSecret(requestToken.getSecret());
   return result;
 }
Ejemplo n.º 2
0
  public OAuthToken getAccessToken(
      String clientId, String clientSecret, String authorizationCode, OAuthToken requestToken) {
    OAuthToken token = null;

    try {
      OAuthService service =
          new ServiceBuilder()
              .provider(LinkedInApi.class)
              .apiKey(clientId)
              .apiSecret(clientSecret)
              .build();
      Verifier verifier = new Verifier(authorizationCode);
      Token reqToken = new Token(requestToken.getToken(), requestToken.getTokenSecret());
      Token accessToken = service.getAccessToken(reqToken, verifier);
      token = new OAuthToken();
      token.setToken(accessToken.getToken());
      token.setTokenSecret(accessToken.getSecret());
    } catch (Exception e) {
      log.error("Error getting AccessToken", e);
    }

    return token;
  }