Running OSX Mavericks, ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0], rvm 1.25.23 (master), and rails-4.1.0 (allegedly)
I'm working through the railsapps.org book on learning rails and am stuck at "Spreadsheet Connection". I have the code exactly as the book spells out, and I have set up an application specific password for Google Drive and tested it. My code looks like the following:
def update_spreadsheet
connection = GoogleDrive.login(Rails.application.secrets.email_provider_username, Rails.application.secrets.email_provider_password)
ss = connection.spreadsheet_by_title('Learn-Rails-Example')
if ss.nil?
ss = connection.create_spreadsheet('Learn-Rails-Example')
end
My secrets.yml file contains the following:
development:
email_provider_username: <%= ENV["GMAIL_USERNAME"] %>
email_provider_password: <%= ENV["GMAIL_PASSWORD"] %>
mailchimp_api_key: <%= ENV["MAILCHIMP_API_KEY"] %>
mailchimp_list_id: <%= ENV["MAILCHIMP_LIST_ID"] %>
and I have my .bashrc file configured correctly per the tutorial.
When I enter the contact form info and press 'submit', I get the following error:
GoogleDrive::AuthenticationError at /contacts
Authentication failed for : Response code 403 for post https://www.google.com/accounts/ClientLogin: Error=BadAuthentication
If I go up and hard code the login and app-specific password in place of Rails.application.secrets.email_provider_username
and Rails.application.secrets.email_provider_password
it works just fine. As a newbie, I'm unable to follow the code to understand where or how Rails.application.secrets.email_provider_username
gets pointed to my .bashrc settings.
Any help is greatly appreciated.
Regards, Jeff