0

Is there a way to know if the logged in user (through linkedin) is/has a company associated ?

I need to allow access to my app only linkedin companies. How can I validate if the logged in user is a linkedin company or a regular user ?

Gustavo
  • 526
  • 1
  • 4
  • 13

1 Answers1

0

The LinkedInProfile class only contains the basic profile information which does not help in distinguishing if the logged in user is a regular user or company. This class extends LinkedInObject which contains extraData property for carrying any data in response from LinkedIn that won't be otherwise mapped to any properties of the subclass.

The getExtraData method returns a Map<String, Object> which contains the extra information. In this Map check if company-type key is available, if YES then you can conclude that the logged in user is of type Company.

The possible values of company-type are:

  • C ("Public Company")
  • D ("Educational")
  • E ("Self Employed")
  • G ("Government Agency")
  • N ("Non Profit")
  • O ("Self Owned")
  • P ("Privately Held")
  • S ("Partnership")
Mithun
  • 7,747
  • 6
  • 52
  • 68
  • I had noticed the extraData() map but it is always empty. Is there an oauth scope I need to send to get those fields populated ? – Gustavo Mar 24 '15 at 15:05
  • ((LinkedIn) connection.getApi()).profileOperations().getUserProfile().getExtraData() All info for userProfile is there, but not the extraData. Nothing special about the config. Just added apply(new SpringSocialConfigurer()); toHttpSecurity – Gustavo Mar 25 '15 at 01:40
  • Instead of `((LinkedIn) connection.getApi()).profileOperations()` use `((LinkedIn) connection.getApi()).companyOperations()` for all company related queries. – Mithun Mar 25 '15 at 05:54
  • all operations inside companyOperations() required an input such as company id, website, etc. Those are the fields that I don't have actually. I need a way of knowing if the profile has/is a company. – Gustavo Mar 25 '15 at 16:51
  • Since you have the logged in user, you could use the ID and invoke the `getCompany(int id)` method. If the response is not null, you could be sure that the logged in user is of type company. – Mithun Mar 25 '15 at 17:09
  • What I have is the user id (which is a string), I don't have the company id (which is an int). companyOperations() is just a class for company related operations but not attached to the logged in user, but any company. – Gustavo Mar 25 '15 at 17:18