How to Import Contacts From Yahoo or Google Using Ruby

I came across this tutorial on how to import contacts from Gmail, Yahoo or Hotmail.

The primary issue I encountered is that the gem doesn’t work for Ruby 1.9. I use Ruby 1.9.2 for all of my Rails projects.

This might be useful for someone who’s trying to get it to work. Just use my fork of the project on your Gemfile.

gem 'contacts', git: "[email protected]:kathgironpe/contacts.git"

The gem uses gdata-19 which is pretty much a fork of the gdata project. I am aware there’s already a gdata19 project but it doesn’t quite work the way it expect it to. I still encountered some issues.

gem install gdata-19

This is now working for me:

Contacts::Gmail.new(gmail_email, gmail_password).contacts

And it’s so fast!

Known Issues:

Security

HTTP authentication is less secure than OAuth.

Make sure you add something like this on your application.rb

    config.filter_parameters << [:gmail_email]
    config.filter_parameters << [:gmail_password]

We don’t store data but there may be security issues. In fact, I don’t use apps that use HTTP authentication. That isn’t possible for e-commerce apps though. Developers still often store card number (and hopefully not the CVV though I have heard of some who do that!)

If anyone knows a gem or can create a gem for importing contacts from yahoo/gmail/hotmail and the gem supports OAuth, please let me know.

Thank you.