Task: import contacts from Gmail.
I use gem omnicontacts.
omnicontacts.rb:
Rails.application.middleware.use OmniContacts::Builder do
importer :gmail, ENV['API_KEY'], ENV['API_SECRET'], {:redirect_path => '/contacts/gmail/callback'}
My controller:
def callback
provider = params[:importer]
@contacts = request.env['omnicontacts.contacts']
@user = request.env['omnicontacts.user']
if @contacts.nil?
session[:message] = {
:text => "Sorry, we didn't find any of your friends at this time. Please try again later.",
:type => 'notice'
}
else
...
end
My routes.rb:
get '/contacts/:importer' => 'contacts_importer#callback', as: :import_contacts
get '/contacts/:importer/callback' => 'contacts_importer#callback'
get '/contacts/failure' => 'contacts_importer#failure'
I do everything as indicated in the documentation https://github.com/Diego81/omnicontacts
But @contacts and @user is always nil.
Why?