Linkedin OAuth2 401 Not Authorized problem
Hi, I used the library for 1 month and it worked great! Thanks for making it. :)
Unfortunately, since november the 1st, it stopped working. To check whether it is a problem of my own code. I downloaded the library again, deployed it on the server and tested the linkedin example.
When I am logged in on linkedin the example is working fine. If i'm not logged in on linkedin, I see the "Accept page" of linkedin, I click on Accept and I am redirected to the example. Then I get the following error:
Fatal error: Uncaught exception 'OAuth\Common\Http\Exception\TokenResponseException' with message 'file_get_contents(https://api.linkedin.com/v1/people/~?format=json&oauth2_access_token=AQWYrEZcx1LMEQLgiVAsnfJV0EXOMnaw_0HX2mcB3YbmpOazNwscvclxSZQtZ-kWi_cd_iJ7Mh0zsqDwUOCAt2qL5OKHiTj2GG_q3PruEKwR7jMMV0dAlUgw-clwl2ik91WNmawJrch3pqwYe0HBDqbd31bmM_LixWbdunZwALRHZwGV0l0) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized ' in /var/www/vhosts/...../httpdocs/public/test/src/OAuth/Common/Http/Client/StreamClient.php:64 Stack trace: #0 /var/www/vhosts/...../httpdocs/public/test/src/OAuth/OAuth2/Service/AbstractService.php(153): OAuth\Common\Http\Client\StreamClient->retrieveResponse(Object(OAuth\Common\Http\Uri\Uri), NULL, Array, 'GET') #1 /var/www/vhosts/...../httpdocs/public/test/examples/linkedin.php(43): OAuth\OAuth2\Service\AbstractService->request('/people/~?forma...') #2 {main} thrown in /var/www/vhosts/..../httpdocs/public/test/src/OAuth/Common/Http/Client/StreamClient.php on line 64
Perhaps Linkedin has changed something? Do you have the same problem?
Thanks in advance, Kind Regards,
Roland
Can this be related: http://developer.linkedin.com/thread/2233?
Is that & on the URL expected..?
Hi. Thanks for your quick response, the help is much appreciated. :)
In streamclient.php, I put a die() after the file_get_contents function and I see that there is a warning:
Warning: file_get_contents(https://api.linkedin.com/v1/people/~?format=json&oauth2_access_token=AQXgKu5BUmWdSNZAivq-uMeh4AL1CZgpL3nX36h9vYJYruGUsTeRqpuc_cdK-hy3UscOXfKJUd7wZ2p36A4VcRYrhhIF6EIQiCZ6cCFPI6VUNrH1kmiaN6Q68cObrvoBrUeNVjk5uatB53dSAuCbyMJWaTBev1vRKY5n2TvBM30FbYHeTKQ) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized in /var/www/vhosts/..../httpdocs/public/test/src/OAuth/Common/Http/Client/StreamClient.php on line 57
The url does not have & amp;, I guess that is from the output of the php exception handler....
As for the link:
- I checked for encoded characters, I can't find any
- I tried to use the https://api.linkedin.com/v1/people/id=NUMBER_OF_MY_LINKEDIN?format=json instead of the ~, same result.
- connection via the LinkedIn Java wrapper, if possible, is not handy for me.
Thanks again, :) Kind Regards,
Roland
Hi, oke, I finally solved the problem. It seems the problem only occurs with the linkedin account I used for testing. I created a new account. With it the library is working fine again. As to why it didn't work anymore with the old account, I really do not know. It worked for one month! Possibly I used it to long for testing, or triggered some security measure... Hopefully someone else will benefit from my problems.... :S
Thanks for your kind response. :)
Closed because you have fixed the issue :)
We also have the same problems authenticating with LinkedIn and we are getting the same error's. We are trying to migrate from the Zend framework oauth 1 libary to this one but we also have this issue with "Not Authorized problem". We tried 3 different LinkedIn accounts and 2 out of 3 have this problem. And the old Zend version is still working with the same users.
While testing I implemented a version of LinkedIn oauth1 class based on the Twitter version like this one and that works like a charm https://gist.github.com/cmodijk/7445418. But if I register this in the ServiceFactory it won't get an instance because it checks the Oauth2 class first...
@cmodijk: It seems that LinkedIn blocks accounts temporarily. The test account that was blocked (see above), is now working fine again. And the account that I created last week, is now blocked... I think LinkedIn blocks it when you authenticate it to often....
@aristotelesweb: Tnx for your response that could be the case it is hard to test this. But what I find strange the oauth 1 version works fine with al the same accounts.
stupid clevers make life hard for us too. Cant find any solution anyway.