3

リンクされたRuby APIを使用して API エンドポイントにメッセージを送信しようとしています:http://api.linkedin.com/v1/people/~/sharesが、このエラーが発生するたびに: LinkedIn::Errors::AccessDeniedError ((403): Access to posting shares denied). なにが問題ですか?

コード:

#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!

スコープ パラメーターを指定する必要がありますか? はいの場合、これをコードに実装するにはどうすればよいですか?

ありがとう

4

1 に答える 1

5

デフォルトのコンシューマー オプションをオーバーライドし、スコープを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)
于 2013-02-19T13:31:29.300 に答える