【问题标题】:Error 401 on API request on RubyRuby 上的 API 请求出现错误 401
【发布时间】:2017-11-22 15:30:43
【问题描述】:

我只想连接到Sellsy API。所以,我写了一个 Ruby 脚本:

require 'oauth'
@consumer = OAuth::Consumer.new("user_key","user_pwd", :site => "https://apifeed.sellsy.com/0/request_token")
puts @consumer
@request_token = @consumer.get_request_token
session[:request_token] = @request_token

我得到一个 401 错误:

#<OAuth::Consumer:0x008dfe229f3c10>
/usr/local/lib/ruby/gems/2.3.0/gems/oauth0.5.3/lib/oauth/consumer.rb:236:in `token_request': 401 Unauthorized (OAuth::Unauthorized)
from /usr/local/lib/ruby/gems/2.3.0/gems/oauth-0.5.3/lib/oauth/consumer.rb:155:in `get_request_token'
from test0.rb:4:in `<main>'

我只想确保我的脚本没有错误,我只想连接到 API(还没有其他请求)。

谢谢。

【问题讨论】:

  • 你见过this吗?虽然没有文档

标签: ruby api oauth


【解决方案1】:

终于找到了解决办法,脚本在这里:https://github.com/bastienrobert/Sellsy-API

【讨论】:

  • 欢迎提供解决方案链接,但请确保您的答案在没有它的情况下有用:add context around the link 这样您的其他用户就会知道它是什么以及为什么会出现,然后引用最相关的您链接到的页面的一部分,以防目标页面不可用。 Answers that are little more than a link may be deleted.
  • 对于任何使用它的人,oauth_signature = URI::escape(self.configuration.consumer_secret) + "&" + URI::escape(self.configuration.user_secret)
猜你喜欢
  • 1970-01-01
  • 2022-01-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-11
  • 2011-04-02
  • 2021-06-19
相关资源
最近更新 更多