gpt4 book ai didi

ruby-on-rails - 使用 linkedin api 发布公共(public)消息时出现 "Access to posting shares denied"错误

转载 作者:数据小太阳 更新时间:2023-10-29 07:53:24 24 4
gpt4 key购买 nike

我正在尝试使用 linkedin ruby api 发送消息到 API 端点:http://api.linkedin.com/v1/people/~/shares,但每次我收到此错误:LinkedIn::Errors::AccessDeniedError (( 403): 访问发布共享被拒绝)。怎么了?

代码:

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

我需要指定范围参数吗?如果是,我该如何在我的代码中实现它?

谢谢

最佳答案

覆盖默认消费者选项并将范围附加到 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)

关于ruby-on-rails - 使用 linkedin api 发布公共(public)消息时出现 "Access to posting shares denied"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14956746/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com