Sreehari K M
Sreehari K M

Reputation: 575

Linkedin Permissions : only serving current position informations

This question is related to the same one here, but still i am facing the same problem that linkedin is only serving the current position informations , how can i get the past positions & education details using the linkedin gem in Rails,my linkedin controller has been shown below, need your assistance.

   require 'linkedin'

   class LinkedinUserController < ApplicationController

   def init_client
     key = "XXXXXX"
     secret = "XXXXXX"
     linkedin_configuration = { :site => 'https://api.linkedin.com',
        :authorize_path => '/uas/oauth/authenticate',
        :request_token_path =>'/uas/oauth/requestToken?scope=r_basicprofile+r_fullprofile+r_emailaddress+r_network+r_contactinfo',
        :access_token_path => '/uas/oauth/accessToken' }

     @linkedin_client = LinkedIn::Client.new(key, secret,linkedin_configuration)
   end

   def auth
     init_client
     request_token = @linkedin_client.request_token(:oauth_callback => "http://#{request.host_with_port}/linkedin/callback")
     session[:rtoken] = request_token.token
     session[:rsecret] = request_token.secret
     redirect_to @linkedin_client.request_token.authorize_url
   end

   def callback
     init_client
     if session[:atoken].nil?
       pin = params[:oauth_verifier]
       atoken, asecret =  @linkedin_client.authorize_from_request(session[:rtoken], session[:rsecret], pin)
       session[:atoken] = atoken
       session[:asecret] = asecret
     else
       @linkedin_client.authorize_from_access(session[:atoken], session[:asecret])
     end

     c = @linkedin_client
     c.profile(:fields=>["first_name","last_name","headline","positions","educations"])
   end
   end

Upvotes: 0

Views: 384

Answers (1)

Cris
Cris

Reputation: 13341

LinkedIn is very particular about access to profile fields and you cannot combine multiple fields which requires 2 different access. so when you try to get just position details by c.profile(:fields => %w(positions)) it assumes the access of type 'r_basicprofile' whereas educations field require access of type 'r_fullprofile'.so try 2 seperate API calls to retrieve both fields.

"first_name","last_name","headline","positions" available for 'r_basicprofile' member permission,so they can be combined together.

Upvotes: 1

Related Questions