Oauth2 LinkedIn problems
Recently I have been implementing signing in to a website using third party services like Facebook, Twitter, Google plus and LinkedIn and fetching user information from those websites.
Developing for Drupal using some contributed modules that do most of the hard work, I faced some problems with LinkedIn so I am going to mention them and some other notices.
Basically I wanted first to sign in with the user account (get a token) then grab some info about the user using this token.
1-To grab the token used for fetching data you use https://www.linkedin.com (the www is very important), the url to get the information is https://api.linkedin.com/v1/people/~ https is important in both.
2-It required a variable to be sent when requesting the token that was not required in Facebook and Google, that was status, this should be a get variable set with some unique value you set it, making the authorization endpoint url should look like this https://www.linkedin.com/uas/oauth2/authorization?state=WHATEVER plus the variables you should send.
3-The default response format is xml, if you want it to be json you will need to state that explicitly in the url by sending a get parameter format=json
4-You have to explicitly set the fields you want to read from the the user profile, or you will be getting basic profile info only, like https://api.linkedin.com/v1/people/~:(first-name,email-address,education)
5-When using json as response format the field names are changed only in the response removing dashes if they exist and camel casing those field names having dashes so if you want to read the field first-name, in the query you should state it as first-name, it will be sent to you with the field name firstName,so as last-name will be lastName, formated-name will be formatedName, etc..
6-Some problem with the protocol itself now with linkedin as if the server is fast enough and you start fetching information as soon as you get the token, it might return you a 401 error (Unauthorized), This is my first thought as when I test through the website it returns the error, and when debugging it works! waiting a couple of seconds might fix that (I didn't test that yet).
Thats it for now...