Gmail::Client::AuthorizationError only in Production for Rails App on Heroku
我有一个 RoR 应用程序,它使用 gmail gem 从我的收件箱中读取电子邮件。我已经部署到 Heroku,一切正常,除了连接到 gmail。
在我的本地计算机上,它可以毫无问题地连接(在我允许不太安全的应用程序访问之后)。
使用基本的gmail登录方式;
1 |
我只在生产中收到以下错误。
然后我会去 https://www.google.com/accounts/DisplayUnlockCaptcha (正如其他答案所建议的那样),它会在短时间内正常工作,然后突然停止工作。
我正在使用 Ruby v2.4.1、RoR v5.1.1 和 gmail gem v0.6.0 (https://github.com/gmailgem/gmail)
任何帮助都会很棒。
您要部署到域吗?这可能是由以下事实引起的:
Heroko will not give you even a range of IP addresses - they can, may and will move dynos between Amazon zones as needs require.
Your only option would be some sort of proxy node with a static IP that they talk to that securely communicates to your Heroku app - or consider if Heroku is the right fit for you here altogether.
来源:为我的 Heroku 应用获取有限的 IP 地址列表?
您似乎登录 Google 并将 IP 列入白名单(就他们而言),然后测功机因某种原因稍后切换,因此 Google 不再将您的测功机 IP 列入此应用的白名单.