Ruby on Rails:用户名/密码错误? (535身份验证失败) [英] Ruby on Rails: bad username / password? (535 Auth failed)

查看:270
本文介绍了Ruby on Rails:用户名/密码错误? (535身份验证失败)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在Bloc完成了红宝石基础课程,现在我开始全心投入铁路开发。事情进展顺利,直到我收到设计和确认电子邮件的建议。我尝试使用谷歌搜索功能,环顾其他问题,但找不到任何能给我带来任何帮助并适用于我的情况的问题。


我收到以下错误消息


Net :: RegistrationController#create


535中的

Net :: SMTPAuthenticationError身份验证失败:用户名/密码错误


从源代码#976处提取错误

  def check_auth_response(res)除非成功,否则

引发SMTPAuthenticationError,res.message
结束
结束




在其他帖子中,我知道您可能希望看到我有一个config / initializers / setup_mail.rb文件,如下所示:

 如果Rails.env.development? 
ActionMailer :: Base.delivery_method =:smtp
ActionMailer :: Base.smtp_settings = {
地址:'smtp.sendgrid.net',
端口:'587',
身份验证::plain,
用户名:ENV ['SENDGRID_USERNAME'],
密码:ENV ['SENDGRID_PASSWORD'],
域:'heroku.com',
enable_starttls_auto:true
}
end




这是一个应用程序.yml文件示例:

  SENDGRID_PASSWORD:
SENDGRID_USERNAME:
SECRET_KEY_BASE:




在有人建议之前,我在config / environments / development.rb中也有以下内容:

  config.action_mailer.default_url_options = {主机:'localhost:3000'} 
config.action_mailer.delivery_method =:smtp
config.action_mailer.perform_deliveries = true
#在开发中覆盖Action Mailer的无提示错误
config.action_mailer.raise_deliver y_errors = true




如果您还想查看其他文件,请告诉我知道,我将它们添加到这篇文章中。

解决方案

恭喜您,欢迎您来到有趣的东西黑客世界。

p>

您收到的错误意味着SendGrid服务器接收到错误的用户名和密码组合。



可能是您的环境变量为空,并且 application.yml 文件未使用您的SendGrid用户名+密码正确加载。



您可以通过在代码中的某些位置将它们打印出来来确认。在控制器中有效。

 放入 SENDGRID_USERNAME:#{ENV ['SENDGRID_USERNAME']} 
放入 SENDGRID_PASSWORD :#{ENV ['SENDGRID_PASSWORD']}

我怀疑它们为零。 / p>

我建议阅读 https:// quickleft.com/blog/simple-rails-app-configuration-settings/ 关于如何将它们来源到您的应用程序中。



请让我知道是否您需要更多帮助!


I just finished my ruby foundations coursework at Bloc and I'm starting to bury my head into rails development. Things were going smooth until I hit this snag with devise and confirmation emails. I tried googling and looking around at some other questions but couldn't really find any that gave me anything that I could pull from and apply to my situation.

I'm receiving the following error when signing up for an account.

Net::SMTPAuthenticationError in Devise::RegistrationsController#create

535 Authentication failed: Bad username / password


Error extracted from source around line #976

def check_auth_response(res)
  unless res.success?
    raise SMTPAuthenticationError, res.message
  end
end


From other posts I know you'll probably want to see that I have a config/initializers/setup_mail.rb file that looks like this:

if Rails.env.development?
  ActionMailer::Base.delivery_method = :smtp
  ActionMailer::Base.smtp_settings = {
    address:        'smtp.sendgrid.net',
    port:           '587',
    authentication: :plain,
    user_name:      ENV['SENDGRID_USERNAME'],
    password:       ENV['SENDGRID_PASSWORD'],
    domain:         'heroku.com',
    enable_starttls_auto: true
  }
end


And here's an application.yml file EXAMPLE:

SENDGRID_PASSWORD: 
SENDGRID_USERNAME:
SECRET_KEY_BASE:


also I have the following in my config/environments/development.rb before anybody suggests it:

config.action_mailer.default_url_options = { host: 'localhost:3000'}
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
# Override Action Mailer's 'silent errors' in development
config.action_mailer.raise_delivery_errors = true


If there's any other files that you'd like to see let me know and I'll add them to this post.

解决方案

Congrats and welcome to the world of hacking on cool things.

The error you are getting means that the SendGrid server received a bad username + password combo.

Chances are your environment variables are empty and your application.yml file isn't being loaded properly with your SendGrid username + password.

You can confirm this by printing them out somewhere in your code. In a controller works.

puts "SENDGRID_USERNAME: #{ENV['SENDGRID_USERNAME']}"
puts "SENDGRID_PASSWORD: #{ENV['SENDGRID_PASSWORD']}"

I'd suspect that they are nil.

I'd recommend reading https://quickleft.com/blog/simple-rails-app-configuration-settings/ about how to get them sourced into your app.

Please let me know if you need any more help!

这篇关于Ruby on Rails:用户名/密码错误? (535身份验证失败)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆