I have connected to facebook and twitter using spring social (spring-social-showcase demo) and it working as very nice. Now I am trying to integrate linkedin api into it.
The pom.xml file is shown bellow.
<properties>
<org.springframework.social.linkedin-version>1.0.0.BUILD-SNAPSHOT</org.springframework.social.linkedin-version>
</properties>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-linkedin</artifactId><version>${org.springframework.social.l inkedin-version}</version>
</dependency>
SocialConfig file is shown bellow.
@Bean
@Scope(value="singleton", proxyMode=ScopedProxyMode.INTERFACES)
public ConnectionFactoryLocator connectionFactoryLocator() {
ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();
registry.addConnectionFactory(new LinkedInConnectionFactory(environment.getProperty( "linkedin.apikey"),
environment.getProperty("linkedin.secretkey")));
return registry;
}
@Bean
@Scope(value="request", proxyMode=ScopedProxyMode.INTERFACES)
public LinkedIn linkedin() {
Connection<LinkedIn> linkedin = connectionRepository().findPrimaryConnection(Linke dIn.class);
return linkedin != null ? linkedin.getApi() : null;
}
And application.properties file is shown bellow
#Linkedin properties
linkedin.apikey=#########
linkedin.secretkey=####################
When I try to connect linkedin using the <form action="<c:url value="/connect/linkedin" />" method="POST"> then it generates the following error
org.springframework.web.client.HttpClientErrorExce ption: 400 Bad Request
org.springframework.web.client.DefaultResponseErro rHandler.handleError(DefaultResponseErrorHandler.j ava:75)
org.springframework.web.client.RestTemplate.handle ResponseError(RestTemplate.java:486)
org.springframework.web.client.RestTemplate.doExec ute(RestTemplate.java:443)
org.springframework.web.client.RestTemplate.execut e(RestTemplate.java:415)
org.springframework.web.client.RestTemplate.exchan ge(RestTemplate.java:391)
org.springframework.social.oauth1.OAuth1Template.e xchangeForToken(OAuth1Template.java:194)
org.springframework.social.oauth1.OAuth1Template.f etchRequestToken(OAuth1Template.java:116)
org.springframework.social.connect.web.ConnectSupp ort.fetchRequestToken(ConnectSupport.java:143)
org.springframework.social.connect.web.ConnectSupp ort.buildOAuth1Url(ConnectSupport.java:136)
org.springframework.social.connect.web.ConnectSupp ort.buildOAuthUrl(ConnectSupport.java:95)
org.springframework.social.connect.web.ConnectCont roller.connect(ConnectController.java:161)
sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
I want to connect linkedin like twitter. Please help.


Reply With Quote
