"Access to posting shares denied" error when posting public messages using the linkedin api

linkedin-api, ruby, ruby-on-rails

Solution

Override the default consumer options and append scope to the `request_token_path`

 consumer_options = {
    :request_token_path => "/uas/oauth/requestToken?scope=r_basicprofile+w_share",
    :access_token_path  => "/uas/oauth/accessToken",
    :authorize_path     => "/uas/oauth/authorize",
    :api_host           => "https://api.linkedin.com",
    :auth_host          => "https://www.linkedin.com"
  }
 LinkedIn::Client.new(ckey, csecret, consumer_options)

Problem

I am trying send out messages using the linkedin ruby api to the API end point : `http://api.linkedin.com/v1/people/~/shares`, but everytime I get this error : `LinkedIn::Errors::AccessDeniedError ((403): Access to posting shares denied)`. What is wrong? code: ``` #fetch client object client = LinkedIn::Client.new('er0xev11ktyj', 'qw7hfgR4wT8Hztpl') #auth request_token = client.request_token(:oauth_callback => callback_url) session[:linkedin_token] = request_token.token session[:linkedin_secret] = request_token.secret redirect_to request_token.authorize_url #inside callback url atoken,asecret = client.authorize_from_request(session[:linkedin_token], session[:linkedin_secret], params[:oauth_verifier]) #api call for posting message client.authorize_from_access(atoken, asecret) client.add_share({:comment => "Hey!"}) #throws error! ``` Do I need to specify scope parameters? If yes, how do I implement this in my code? Thanks

Original source