Auth0 Ruby Rails TCP 错误

Auth0 Ruby on Rails TCP Error

我正在使用 Auth0 的 Ruby on Rails API Sample as boilerplate to set up authentication with a new app. Everything is working up to but not including the "Test Your API with cURL" step on the second page of the instructions

我尝试使用 cURL 和 Postman 进行测试,但两次都收到以下错误:

Errno::ECONNREFUSED 在 PrivateController#private 中。无法打开到 :443 的 TCP 连接(连接被拒绝 - 连接(2)为 nil 端口 443)

突出显示的错误行如下:jwks_raw = Net::HTTP.get URI("https://#{Rails.application.secrets.auth0_domain}/.well-known/jwks.json").

当我直接克隆示例存储库并尝试使用我的访问令牌进行测试时,我收到了同样的错误,所以这似乎是他们示例中的疏忽或过时的代码,而不是我将其合并到其中时出现的错误我自己的应用程序。

我该如何解决?

确保将 auth0_domain 密码传递给 rails 应用程序时已设置。

如果该值为空,它会使您的初始字符串无效 URL,即 "https://#{Rails.application.secrets.auth0_domain}/.well-known/jwks.json" 变成 "https:///.well-known/jwks.json"

my case 中,我使用了一个空环境变量,它返回 nil:

ENV['AUTH0_DOMAIN']
=> nil

希望这个回答对您有所帮助!