Hello,
I'm trying Spring Social 1.0.0.RC1. Section-2 ("2. Service Provider
'Connect' Framework") of the reference manual provides examples for
establishing connections to Facebook and Twitter. I have been able
to use the example code to connect to both providers.
Now I'm trying to connect to LinkedIn. I'm using the Twitter example
code as a reference because the Spring Social reference states that
both Twitter and LinkedIn use OAuth1. The code seems to be successful
with the first part of the oauth dance which returns an "oauth_token"
and "oauth_verifier" from LinkedIn.
But the code encounters an error trying to obtain an access token
via the "exchangeForAccessToken method. Here is the error:
org.springframework.web.client.HttpClientErrorExce ption: 401 Unauthorized
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:195)
org.springframework.social.oauth1.OAuth1Template.e xchangeForAccessToken(OAuth1Template.java:133)
com.hp.it.services.social.socialso.service.LinkedI nManagerImpl.finalizeConnection(LinkedInManagerImp l.java:100)
com.hp.it.services.social.socialso.controller.Link edInCallbackController.handleRequest(LinkedInCallb ackController.java:50)
org.springframework.web.servlet.mvc.SimpleControll erHandlerAdapter.handle(SimpleControllerHandlerAda pter.java:48)
org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:790)
org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:644)
org.springframework.web.servlet.FrameworkServlet.d oGet(FrameworkServlet.java:549)
javax.servlet.http.HttpServlet.service(HttpServlet .java:617)
javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
Here's the relevant code:
LinkedInConnectionFactory connectionFactory = new LinkedInConnectionFactory(apiKey, secretKey);
OAuth1Operations oAuthOperations = connectionFactory.getOAuthOperations();
OAuthToken oAuthToken = new OAuthToken(oAuthTokenStr, secretKey);
OAuthToken accessToken = oAuthOperations.exchangeForAccessToken(
new AuthorizedRequestToken(oAuthToken, oAuthVerifierStr), null);
Here's a relevant snipit from my maven pom file:
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-linkedin</artifactId>
<version>1.0.0.M3</version>
</dependency>
Note that I couldn't seem to locate an RC1 version of spring-social-linkedin.
Does anyone have any ideas of what might be causing the error?
Thanks.


Reply With Quote