【问题标题】:How do I debug Omniauth and Rack applications?如何调试 Omniauth 和 Rack 应用程序?
【发布时间】:2012-10-28 15:32:54
【问题描述】:

我正在尝试使用 Rack + omniauth(实际上 - omniauth-ebay)通过 eBay 进行身份验证。我有一个正确的配置(而不是“111”,“222”......有真正的价值):

#config.rb
 use OmniAuth::Builder do
     provider :ebay, "111", "222", "333", "4444", "0", "https://api.sandbox.ebay.com/wsapi" 
 end

当我转到 localhost:9292/auth/ebay 时,我收到以下错误:

    NoMethodError at /auth/ebay
    undefined method `[]' for nil:NilClass
    file: ebay_api.rb location: generate_session_id line: 21

 #....
omniauth.error  - <NoMethodError: undefined method `[]' for nil:NilClass>
omniauth.error.strategy - #<OmniAuth::Strategies::Ebay>
omniauth.error.type - "Failed to retrieve session id from ebay"
omniauth.strategy - <OmniAuth::Strategies::Ebay>

我想知道如何调试它?特别是 localhost:9292/auth/ebay 的路径,因为我没有在我的应用程序中定义它,因为 Omniauth 嵌入它会自动。

你的想法?

【问题讨论】:

    标签: ruby debugging gem rack


    【解决方案1】:

    Omniauth ebay 使用纯 XML 版本的 eBay API,而不是 SOAP 版本。您的最后一个配置值应该是

    https://api.sandbox.ebay.com/ws/api.dll
    

    不是

    https://api.sandbox.ebay.com/wsapi
    

    附带说明,根据您的错误ebay_api.rb,您似乎安装了较早版本的omniauth-ebay gem。在latest version,有更多的错误检查,应该给你更多的细节。

    【讨论】:

    • 没错,现在url是正确的。但是我用的是最新版本,我刚安装。
    • 但现在它会将我重定向到生产登录网址,即signin.ebay.com/ws/eBayISAPI.dll。如何使用沙盒 url - signin.sandbox.ebay.com/ws/eBayISAPI.dll ?
    • 不幸的是,这个值是硬编码在ebay_api.rb中的。你可以在本地更改这个EBAY_LOGIN_URL
    • 我试图在 config.rb 中的 use OmniAuth::Builder do... 之后设置 EbayAPI::EBAY_LOGIN_URL = "signin.sandbox.ebay.com/ws/eBayISAPI.dll。它把我重定向到http://localhost:9292/auth/signin.sandbox.ebay.com/ws/eBayISAPI.dll?....,这是错误的。我应该在另一个地方打电话给EbayAPI::EBAY_LOGIN_URL =..吗?你有什么想法?
    • 看起来这里的迷你 Markdown 编辑器去掉了 https://。将 EBAY_LOGIN_URL 设置为 https://signin.sandbox.ebay.com/ws/eBayISAPI.dll
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多