spring-attic / spring-social-linkedin

LinkedIn API binding and connect support.
http://projects.spring.io/spring-social-linkedin
Apache License 2.0
72 stars 71 forks source link

Linked In Cookie error using spring-social OAuth2.0 #70

Open Aatika-Fatima opened 7 years ago

Aatika-Fatima commented 7 years ago

2017-08-17 09:58:21.806 WARN 12860 --- [nio-9000-exec-2] o.a.h.c.protocol.ResponseProcessCookies : Cookie rejected [lang="v=2&lang=en-us", version:1, domain:linkedin.com, path:/, expiry:null] Domain attribute "linkedin.com" violates RFC 2109: domain must start with a dot

2017-08-17 09:58:21.807 WARN 12860 --- [nio-9000-exec-2] o.a.h.c.protocol.ResponseProcessCookies : Invalid cookie header: "Set-Cookie: lidc="b=SB35:g=21:u=64:i=1502944102:t=1502980850:s=AQFYCdrCW-2W-a_tw-PktdrHLsAjyA2O"; Expires=Thu, 17 Aug 2017 14:40:50 GMT; domain=.linkedin.com; Path=/". Invalid 'expires' attribute: Thu, 17 Aug 2017 14:40:50 GMT

shohoku11wrj commented 6 years ago

I have the same error when using Spring OAuth2.0 to handle LinkedIn. I can get the AccessToken, but failed to call those APIs to get the user's profile or email address.

`2017-10-11 11:15:03.722 TRACE 18454 --- [nio-9090-exec-4] c.a.n.i.c.s.impl.OAuth2ServiceImpl : Authorization Code Response: OAuth2ResponseVo(accessToken=.........-B71wpxYC....rS03fCPP-QMZ00e........9h-XjggWOBrC1............, idToken=null, expiresIn=5183999, tokenType=null, refreshToken=null)

2017-10-11 11:15:03.861 WARN 18454 --- [/O dispatcher 1] o.a.h.c.protocol.ResponseProcessCookies : Invalid cookie header: "Set-Cookie: lidc="b=OB32:g=497:u=1:i=1507745703:t=1507832103:s=AQEM7HBCpRTfQ7zybFhaJcou3npEm7BS"; Expires=Thu, 12 Oct 2017 18:15:03 GMT; domain=.linkedin.com; Path=/". Invalid 'expires' attribute: Thu, 12 Oct 2017 18:15:03 GMT

2017-10-11 11:15:03.862 WARN 18454 --- [nio-9090-exec-4] o.s.web.client.AsyncRestTemplate : Async GET request for "https://api.linkedin.com/v1/people/~:(email-address)?format=json" resulted in 401 (Unauthorized); invoking error handler

2017-10-11 11:15:03.863 ERROR 18454 --- [nio-9090-exec-4] c.a.n.i.c.s.impl.OAuth2ServiceImpl : Failed to get email from url: https://api.linkedin.com/v1/people/~:(email-address)?format=json `

shohoku11wrj commented 6 years ago

I finally solved the issue by manually setting the AccessToken in the request header.

HttpHeaders headers = new HttpHeaders(); headers.set("Authorization", "Bearer " + responseVo.getAccessToken()); HttpEntity entity = new HttpEntity(headers); ListenableFuture<ResponseEntity<OAuth2ProfileResponseVo>> future = externalRestTemplate.exchange(getProfileUri(provider), HttpMethod.GET, entity, OAuth2ProfileResponseVo.class);