Authentication error while fetching gmail contacts using blackbook

Blackbook gem can be used to fetch contacts from gmail, yahoo and hotmail address books. However I recently found out that it would throw up a 'Must be authenticated to access contacts' error everytime I tried to import gmail contacts. On digging deeper, I found out that google has changed the contents of its cookie and blackbook uses this cookie to make sure that the user is authenticated. To fix the issue, you just need to make a one line change in the function scrape_contacts in the file lib/blackbook/importer/gmail.rb. Change
unless agent.cookies.find{|c| c.name == 'GAUSR'  &&
  c.value == "mail:#{options[:username]}"}
raise( Blackbook::BadCredentialsError, "Must be authenticated to access contacts." )
to
unless agent.cookies.find{|c| c.name == 'GAUSR' &&
  (c.value =~ /mail.*:#{options[:username]}/)!=nil}
raise( Blackbook::BadCredentialsError, "Must be authenticated to access contacts." )
If you want to install the updated gem instead of making the change, you can find it in my blackbook fork. My fork also includes the myspace address book import

blog comments powered by Disqus
Hana Mohan
Hana Mohan