我想使用linkedin gem連接到linkedin API。我有以下代碼:使用linkedin紅寶石gem的OAuth問題
require "rubygems"
require "yaml"
require "linkedin"
config = YAML.load_file("config.yml")
client = LinkedIn::Client.new(config["linkedin"]["consumer_key"], config["linkedin"]["consumer_secret"])
rtoken = client.request_token.token
rsecret = client.request_token.secret
puts client.request_token.authorize_url
puts "Access this URL get the PIN and paste it here:"
pin = gets
puts client.authorize_from_request(rtoken, rsecret, pin)
當我運行這段代碼,每一步的OAuth工作正常,除了最後一個(authorize_from_request
)。它給出了以下錯誤:
/Library/Ruby/Gems/1.8/gems/oauth-0.4.4/lib/oauth/consumer.rb:181:in `request': additional_authorization_required (OAuth::Problem)
from /Library/Ruby/Gems/1.8/gems/oauth-0.4.4/lib/oauth/consumer.rb:197:in `token_request'
from /Library/Ruby/Gems/1.8/gems/oauth-0.4.4/lib/oauth/tokens/request_token.rb:18:in `get_access_token'
from /Library/Ruby/Gems/1.8/gems/linkedin-0.2.2/lib/linked_in/authorization_helpers.rb:28:in `authorize_from_request'
from linked_in.rb:17
是我的代碼丟失了什麼?需要額外的授權?
按照OAuth的文檔:
additional_authorization_required: The access token does not have the correct access scopes.
我還是不明白,爲什麼訪問令牌不正確的訪問範圍。
感謝
我怎麼會錯過!謝謝分配;) – rogeriopvl 2011-07-08 11:04:59
不用擔心 - 我其實也有同樣的問題:) – 2011-07-08 16:20:33