问题标签 [faraday]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
3733 浏览

ruby-on-rails - Faraday::ConnectionFailed(到达文件末尾)

我正在使用 Oauth2 Gem 连接到服务。

我可以收到授权代码,但是当我使用该代码检索用户令牌时,我得到 Faraday::ConnectionFailed(到达文件末尾):

大多数其他问题都归因于过期的证书。但是,当我部署到 Heroku 时,此错误仍然存​​在。

0 投票
1 回答
1025 浏览

ruby - GitHub OAuth authorize request doesn't redirect to Authorize Application page

I've implemented my own classes for handling authorization via OAuth to GitHub using Faraday in Ruby. I've verified that under the following conditions:

  • Not logged into GitHub
  • No token exists for the app

that a request for authorization via GET to "/login/oauth/authorize" with a random state variable:

  • Redirects to the GitHub login page
  • Redirects to the Authorize Application page after login
  • Executes callback to my app with temporary code after authorizing
  • Responds with access_token when I POST to "/login/oauth/access_token" with temporary code

The problem I have is when I alter the first condition, I'm not already logged into GitHub. The same GET request is sent to GitHub, I see the correct URL with the right parameters. I then see what appears to be the correct redirect by GitHub with a return_to parameter, but it quickly just redirects again back to the GitHub home page.

I'm hoping it's something easy like forgetting a header parameter or something, and someone might spot the problem right away. Anyway, any help is appreciated...

Code to setup Faraday connection:

Code to send authorization request:

I didn't show the code, but my controller does a redirect to the URL reply from request_authorization(). Again, I definitely see the redirect from my controller in both cases, but the second case seems to encounter something GitHub didn't like in the redirected request. I assume it then redirects to the home page and never replies to my app because of this unknown problem in my original request.

Thanks, David

0 投票
0 回答
405 浏览

ruby-on-rails - Heroku 上 Rails 4 中的 Faraday::Error::ResourceNotFound

我的生产服务器在提交表单时出错。日志说:

这里的整个错误:http: //pastebin.com/8YyWvC93

这是一个艰难的过程,因为它只发生在我的 heroku 服务器上,但我无法在本地解决错误,因为我无法通过客户端 API 的身份验证。

认识到错误?关于在哪里寻找修复它的任何提示?

0 投票
2 回答
752 浏览

ruby-on-rails - faraday builder使用multixml解析body

我想设置法拉第使用 multi_xml 并默认解析我的响应正文。

导致:

宝石中的第 59 行:

0 投票
2 回答
775 浏览

ssl - Omniauth FB 和 Twitter 导致 SSL 错误 (Faraday::SSLError & OpenSSL::SSL::SSLError)

我有一个运行omniauth-facebook 和omniauth-twitter 的Rails 4 应用程序,但是所有登录尝试都会遇到Faraday::SSLError -- SSL_connect returned=1 errno=0 state=SSLv3 read server key exchange B: bad ecpoint (for Facebook)和一个 OpenSSL::SSL::SSLError -- SSL_connect returned=1 errno=0 state=SSLv3 read server key exchange B: bad ecpoint (for Twitter.)

我尝试使用以下方法完全禁用 SSL 对等验证,但无济于事:

配置/初始化程序/omniauth.rb

我还尝试了一堆根证书解决方案,例如:

但无济于事。

有什么建议么?谢谢。

0 投票
0 回答
284 浏览

ruby - 使用 FaradayMiddleware::Caching 缓存的数据

我使用法拉第请求 api。我想缓存响应正文并使用它来代替指定过期时间的请求。

我找到了 FaradayMiddleware::Caching 并且我可以缓存响应正文,但我不知道如何使用缓存而不是请求。

我使用的 API 服务不支持 http 缓存,所以我不能使用 faraday-http-cache gem。

在我的代码下面

如何使用缓存数据而不是正常响应?

缓存键是请求 url,但 url 是动态变化的。所以我想我需要一种方法来获取法拉第构造的 url。

0 投票
1 回答
8102 浏览

http - 法拉第对 getpocket API 的 POST 请求

我正在尝试为我的 Rails 应用程序的用户设置 OAuth 到 GetPocket ( http://getpocket.com )。

在 Pocket Authentication 文档 ( http://getpocket.com/developer/docs/authentication ) 的第 2 步中,我在构建确切的法拉第请求时遇到了麻烦。

以下请求有效:

但我希望响应以 JSON 格式。我希望能够在请求中添加一个 "Content-Type":"application/json" 标头,但我所有的尝试似乎都不起作用。

有趣的是,当我执行以下操作时,请求失败(它返回 200 但不返回请求令牌,只是返回整个 HTML 页面):

如何将我的 Faraday POST 请求发送到 Pocket API 以返回 JSON 格式的结果?

0 投票
1 回答
5787 浏览

ruby-on-rails - 将用户数据发送到远程网络服务器时,法拉第超时错误 ReadTimeout

问题: 当我将数据发布到我们的远程 Web 服务时,我遇到了来自 Faraday 的以下错误。此错误发生在随机用户的随机场合。

错误:

更多信息: 我也无法真正重现它,我尝试不将任何内容返回到 rails 但这会产生不同的错误。

当我查看其他 SO 主题时,我没有得到解决这个问题的真正解决方案,有些人建议增加超时时间,但我认为它相当高。

执行请求(执行请求 POST/GET):

连接:

其他版本信息:

感谢任何有解决此问题的建议的人。

0 投票
1 回答
809 浏览

ruby-on-rails - 使用 Ruby 和 Faraday 转换传入的 JSON 密钥?

我正在使用 Faraday 从 Web 服务中检索 JSON 编码的对象,但是 Web 服务使用可怕的键字符串作为键:值对,例如我想要 'description' 的 'Memo' 和我想要 'manager' 的 'projectManager' .

如何在法拉第检索密钥并将结果插入 Ruby 哈希时对其进行转换?

我希望这是一个已解决的问题,但确实很难找到。(我看到很多帖子询问有关在 JSON.parse() 中将符号转换为字符串的问题)。

0 投票
1 回答
2533 浏览

ruby - 将二进制数据与法拉第

我正在尝试使用法拉第(使用默认适配器)将一些二进制数据放入 url。

我尝试使用 curl 执行的请求是:

在法拉第,我可能以错误的方式设置请求:

以前有人设法用这个宝石做这样的事情吗?

ngw