Giter Club home page Giter Club logo

omnicontacts's Introduction

OmniContacts

Inspired by the popular OmniAuth, OmniContacts is a library that enables users of an application to import contacts from their email or Facebook accounts. The email providers currently supported are Gmail, Yahoo and Hotmail. OmniContacts is a Rack middleware, therefore you can use it with Rails, Sinatra and any other Rack-based framework.

OmniContacts uses the OAuth protocol to communicate with the contacts provider. Yahoo still uses OAuth 1.0, while Facebook, Gmail and Hotmail support OAuth 2.0. In order to use OmniContacts, it is therefore necessary to first register your application with the provider and to obtain client_id and client_secret.

Contribute!

Me (rubytastic) and the orginal author Diego don't actively use this code at the moment, anyone interested in maintaining and contributing to this codebase please write me up in a personal message ( rubytastic ) I try to merge pull requests in every once and a while but this code would benefit from someone actively use and contribute to it.

Gem build updates

There is now a new gem build out which should address many issues people had when posting on the issue tracker. Please update to the latest GEM version if you have problems before posting new issues.

Usage

Add OmniContacts as a dependency:

gem "omnicontacts"

As for OmniAuth, there is a Builder facilitating the usage of multiple contacts importers. In the case of a Rails application, the following code could be placed at config/initializers/omnicontacts.rb:

require "omnicontacts"

Rails.application.middleware.use OmniContacts::Builder do
  importer :gmail, "client_id", "client_secret", {:redirect_path => "/oauth2callback", :ssl_ca_file => "/etc/ssl/certs/curl-ca-bundle.crt"}
  importer :yahoo, "consumer_id", "consumer_secret", {:callback_path => "/callback"}
  importer :linkedin, "consumer_id", "consumer_secret", {:redirect_path => "/oauth2callback", :state => '<long_unique_string_value>'}
  importer :hotmail, "client_id", "client_secret"
  importer :outlook, "app_id", "app_secret"
  importer :facebook, "client_id", "client_secret"
end

Every importer expects client_id and client_secret as mandatory, while :redirect_path and :ssl_ca_file are optional (except linkedin - state arg mandatory). Since Yahoo implements the version 1.0 of the OAuth protocol, naming is slightly different. Instead of :redirect_path you should use :callback_path as key in the hash providing the optional parameters. While :ssl_ca_file is optional, it is highly recommended to set it on production environments for obvious security reasons. On the other hand it makes things much easier to leave the default value for :redirect_path and :callback path, the reason of which will be clear after reading the following section.

Register your application

Note:

Please go through MSDN if above Hotmail link will not work.
Outlook is a newer Microsoft API which allows to retrieve real email address instead of email_hashes when using Hotmail, it also works with all kinds of MS accounts (Office 365, Hotmail.com, Live.com, MSN.com, Outlook.com, and Passport.com).

Integrating with your Application

To use the Gem you first need to redirect your users to /contacts/:importer, where :importer can be facebook, gmail, yahoo or hotmail. No changes to config/routes.rb are needed for this step since OmniContacts will be listening on that path and redirect the user to the email provider's website in order to authorize your app to access his contact list. Once that is done the user will be redirected back to your application, to the path specified in :redirect_path (or :callback_path for yahoo). If nothing is specified the default value is /contacts/:importer/callback (e.g. /contacts/yahoo/callback). This makes things simpler and you can just add the following line to config/routes.rb:

  match "/contacts/:importer/callback" => "your_controller#callback"

The list of contacts can be accessed via the omnicontacts.contacts key in the environment hash and it consists of a simple array of hashes. The following table shows which fields are supported by which provider:

Provider :email :id :profile_picture :name :first_name :last_name :address_1 :address_2 :city :region :postcode :country :phone_number :birthday :gender :relation
Gmail X X X X X X X X X X X X X X X
Facebook X X X X X X X X
Yahoo X X X X X X X X X X X
Hotmail X X X X X X X X
Outlook X X X X X X X X X X X
Linkedin X X X X X

Obviously it may happen that some fields are blank even if supported by the provider in the case that the contact did not provide any information about them.

The information for the logged in user can also be accessed via 'omnicontacts.user' key in the environment hash. It consists of a simple hash which includes the same fields as above.

The following snippet shows how to simply print name and email of each contact, and also the the name of logged in user:

def contacts_callback
  @contacts = request.env['omnicontacts.contacts']
  @user = request.env['omnicontacts.user']
  puts "List of contacts of #{@user[:name]} obtained from #{params[:importer]}:"
  @contacts.each do |contact|
    puts "Contact found: name => #{contact[:name]}, email => #{contact[:email]}"
  end
end

If the user does not authorize your application to access his/her contacts list, or any other inconvenience occurs, he/she is redirected to /contacts/failure. The query string will contain a parameter named error_message which specifies why the list of contacts could not be retrieved. error_message can have one of the following values: not_authorized, timeout and internal_error.

Tips and tricks

OmniContacts supports OAuth 1.0 and OAuth 2.0 token refresh, but for both it needs to persist data between requests. OmniContacts stores access tokens in the session. If you hit the 4KB cookie storage limit you better opt for the Memcache or the Active Record storage.

Gmail requires you to register the redirect_path on their website along with your application. Make sure to use the same value present in the configuration file, or /contacts/gmail/callback if using the default. Also make sure that your full url is used including "www" if your site redirects from the root domain.

To configure the max number of contacts to download from Gmail, just add a max results parameter in your initializer:

importer :gmail, "xxx", "yyy", :max_results => 1000

Yahoo requires you to configure the Permissions your application requires. Make sure to go the Yahoo website and to select Read permission for Contacts.

Hotmail presents a "peculiar" feature. Their API returns a Contact object which does not contain an e-mail field! However, if the contact has either name, family name or both set to null, than there is a field called name which does contain the e-mail address. This means that it may happen that an Hotmail contact does not contain the email field.

Integration Testing

You can enable test mode like this:

  OmniContacts.integration_test.enabled = true

In this way all requests to /omnicontacts/provider will be redirected automatically to /omnicontacts/provider/callback.

The mock method allows to configure per-provider the result to return:

  OmniContacts.integration_test.mock(:provider_name, :email => "[email protected]")

You can either pass a single hash or an array of hashes. If you pass a string, an error will be triggered with subsequent redirect to /contacts/failure?error_message=internal_error

You can also pass a user to fill omnicontacts.user (optional)

  OmniContacts.integration_test.mock(:provider_name, {:email => "[email protected]"}, {:email => "[email protected]"})

Follows a full example of an integration test:

  OmniContacts.integration_test.enabled = true
  OmniContacts.integration_test.mock(:gmail, :email => "[email protected]")
  visit '/contacts/gmail'
  page.should have_content("[email protected]")

Working on localhost

Since Hotmail and Facebook do not allow the usage of localhost as redirect path for the authorization step, a workaround is to use ngrok. This is really useful when you need someone, the contacts provider in this case, to access your locally running application using a unique url.

Install ngrok, download from:

https://ngrok.com/

https://github.com/inconshreveable/ngrok

Unzip the file

unzip /place/this/is/ngrok.zip

Start your application

$ rails server

=> Booting WEBrick
=> Rails 4.0.4 application starting in development on http://0.0.0.0:3000

In a new terminal window, start the tunnel and pass the port where your application is running:

./ngrok 3000

Check the output to see something like

ngrok                                                                                                                    (Ctrl+C to quit)

Tunnel Status                 online
Version                       1.6/1.5
Forwarding                    http://274101c1e.ngrok.com -> 127.0.0.1:3000
Forwarding                    https://274101c1e.ngrok.com -> 127.0.0.1:3000
Web Interface                 127.0.0.1:4040
# Conn                        0
Avg Conn Time                 0.00ms

This window will show all network transaction that your locally hosted application is processing. Ngrok will process all of the requests and responses on your localhost. Visit:

http://123456789.ngrok.com # replace 123456789 with your instance

Example application

Thanks to @sonianand11, you can find a full example of a Rails application using OmniContacts at: https://github.com/sonianand11/omnicontacts_example

Thanks

As already mentioned above, a special thanks goes to @sonianand11 for implementing an example app. Thanks also to @asmatameem for her huge contribution. She indeed added support for Facebook and for many fields which were missing before.

License

Copyright (c) 2012-2013 Diego81

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

omnicontacts's People

Contributors

asmatameem avatar brahmana avatar constantine-nikolaou avatar diego81 avatar gdiggs avatar goddamnyouryan avatar hasghari avatar jdiprete avatar karann avatar katiemccann avatar kbravi avatar kentosasa avatar mateuy-dev avatar mayerseidman avatar mkdynamic avatar nadaaldahleh avatar pfbernardo avatar pvos avatar rahul100885 avatar randyv12 avatar rewritten avatar rolme avatar rtdp avatar rubytastic avatar seanshealy avatar smingins avatar swanandp avatar townie avatar troex avatar xxswingxx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

omnicontacts's Issues

How to get user's token and email address?

Is there a way to get the email address of the user who fetched the records, as well as secret token to store in database so that he doesn't have to authorize it every time. I need it for gmail. There should be a guide for it in README.

Page Renders an error when refreshing the page rendered by the callback.

I'm just wondering if this is an existing issue or not, or if we just implemented it wrongly. After providing my credentials and agreeing on gmail/yahoo authentication it renders my callback page with the list of my contacts. Now when I tried to refresh the page it renders a Routing Error.

No route matches [GET] "/contacts/failure"

Please let me know your thoughts on this.

Thanks,
marc

Exception while fetching Hotmail contacts because HTTP 'headers' is being passed as Array instead of Hash

In the code at this line : https://github.com/Diego81/omnicontacts/blob/master/lib/omnicontacts/http_utils.rb#L77 the headers argument has a default value of an empty Array and that is what gets passed on to the Ruby's HTTP implementation resulting in an exception because Ruby's HTTP library expects it to be a Hash.

Relevant documentation is here : https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L1090

The exception occurs at this point : https://github.com/ruby/ruby/blob/trunk/lib/net/http/generic_request.rb#L34 where it is trying to see if initheader has any keys, but the Array object that is sent from earlier does not respond to keys method resulting in NoMethodError.

The change needed to fix this is minimal. The [] should change to {}. I am submitting a pull request regarding the same.

Note : In practice this error occurs only with Hotmail importer. Gmail importer providers its own Hash of headers, overriding the default value and Yahoo importer uses the http_get method which does not have headers parameter.

Error redirecting

I'm trying to integrate omnicontacts in sinatra and, because sinatra uses lint, I'm getting the following error if I'm not in production mode when the browser tries to redirect. This happens to hotmail, gmail and yahoo:

Rack::Lint::LintError at /contacts/yahoo
No Content-Type header found

Ruby ruby/gems/1.9.1/gems/rack-1.3.0/lib/rack/lint.rb: in assert, line 19

To ensure Rack protocol is being followed, there must be a Content-type header in all responses, except when the status is 1xx, 204 or 304.

So, for example, in:
[302, {"location" => authorization_url}, []] you need to change to:
[302, {Content-Type" => "respective_content_type", "location" => authorization_url}, []]

This need to be done in every place where you are returning a http status like the line above.

I think for the redirect url the content type would be "application/x-www-form-urlencoded"

client_secret no longer exists?

Thanks for writing this great gem, I try to make it work in my app but the client_secret is no longer available in the google api console.

Or does one have to enable any of the api's in the google api console? Its very unclear at this point, could you perhaps please upgrade the docs with a step by step on how to set it up?

Thanks in advanche for all your hard work on this gem it rocks

I tried with below keeping client_secret empty ( no idea where to find it else )

initializer:

require "omnicontacts"

Rails.application.middleware.use OmniContacts::Builder do
#importer :gmail, "xxx.apps.googleusercontent.com", "", {:redirect_path => "/oauth2callback", :ssl_ca_file => "/etc/ssl/certs/curl-ca-bundle.crt"}
importer :gmail, "xxx.apps.googleusercontent.com", "", {:redirect_path => "/callback", :ssl_ca_file => "/etc/ssl/certs/curl-ca-bundle.crt"}
importer :yahoo, "consumer_id", "consumer_secret", {:callback_path => '/callback'}
importer :hotmail, "client_id", "client_secret"
end

this results in:

invalid_client error

scope=https://www.google.com/m8/feeds
response_type=code
access_type=offline
redirect_uri=http://mydomain.com/oauth2callback
approval_prompt=force
client_id=client_id

And where should the .crt be placed ( what file is this and how to use it?)

Internal-error when getting yahoo contacts

** UPDATE ** working now...apparently any error in the controller method handling the callback raises an internal_error. In my case, this statement "raise request.env["omnicontacts.contacts"].to_yaml" was causing the error, no idea why.

After clicking the link to get yahoo contacts i get redirected to
"/contacts/failure?error_message=internal_error"

In the rails console, i get this message:
"Error internal_error while processing /contacts/yahoo/callback" followed by my contacts.

So my contacts are being fetched but the error is also thrown. Any ideas as to why this would happen? It would be helpful if internal_error was a little verbose about what the actual error is.

open oath window in popup and redirect the callback parent page somehow?

Many of the bigger websites use oath and have a popup for the auth window.
So your application is below the oath popup.

Is there some way to achieve this or is this impossible?

Im looking into the options at this moment as I have done before ut havent been able to get something solid working.

Yahoo OAUTH1 Issues

omnicontacts 0.2.0

The callback catches the redirect from Yahoo after giving permission to the application, but errors occur.

I was getting this first:
NoMethodError (undefined method `<=>' for :oauth_signature_method:Symbol):

Then after implementing hotmail, I tried again, and got this:
NoMethodError (undefined method `<=>' for :view:Symbol):

After commenting out this in the yahoo.rb
#:view => "compact"

The first error returned again, commenting that out just lead to another error on another item in the hash, and so on. This seems like a syntax issue with rails, not necessarily the plugin, but I'm not sure.

request.env['omnicontacts.contacts'] is empty in my callback when inviting hotmail contacts

I have the gem working for gmail. I can see the list of contacts in

@contacts = request.env['omnicontacts.contacts']

However, when importing via hotmail, the list is empty. I made sure that I have hotmail contacts. I double checked every settings in my live application (secret key, domain...)

Has anyone had a similar issue ? What can I try to diagnose further ?

Rack:Lint errors in development mode

Rack::Lint is automatically turned on in development mode and it causes errors when you redirect to a provider. So when I go to /contacts/yahoo I get

Rack::Lint::LintError at /contacts/yahoo
No Content-Type header found

Ruby /Users/.../.rvm/gems/ruby-1.9.2-p0/gems/rack-1.4.1/lib/rack/lint.rb: in assert, line 19
Web GET 127.0.0.1/contacts/yahoo
(more info given in the end)

These errors do not appear in test or production mode because Rack::Lint is turned off in test mode...

Looking around I saw a similar issue and patch here ... demandforce/rack-oauth2-server#31 and renatosnrg/rack-oauth2-server@03cd9ef

Can you integrate a similar solution while redirecting ?

More Debug Info :
GET
No GET data.
POST
No POST data.
Rack ENV
Variable Value
HTTP_ACCEPT
text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
HTTP_ACCEPT_CHARSET
ISO-8859-1,utf-8;q=0.7,*;q=0.3
HTTP_ACCEPT_ENCODING
gzip,deflate,sdch
HTTP_ACCEPT_LANGUAGE
en-US,en;q=0.8
HTTP_CONNECTION
keep-alive
HTTP_COOKIE
remember_user_token=BAhbB1sGaV1JIiIkMmEkMTAkRVdIYnBkUWNHSGoyN2tRN3JpWDZHTwY6BkVU--7b1f213ca394eca4af5267caf05bc3c610d6282c; _session_id=02a91f0ed24c086ca1b5672dcfd2ca55
HTTP_HOST
127.0.0.1:8081
HTTP_REFERER
http://127.0.0.1:8081/rewards/friends
HTTP_USER_AGENT
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.57 Safari/537.1
HTTP_VERSION
HTTP/1.1
ORIGINAL_FULLPATH
/contacts/yahoo
PATH_INFO
/contacts/yahoo
QUERY_STRING
REMOTE_ADDR
127.0.0.1
REQUEST_METHOD
GET
REQUEST_PATH
/contacts/yahoo
REQUEST_URI
/contacts/yahoo
SCRIPT_NAME
SERVER_NAME
127.0.0.1
SERVER_PORT
8081
SERVER_PROTOCOL
HTTP/1.1
SERVER_SOFTWARE
Unicorn 4.3.1

Unable to get contacts from yahoo

I have got contacts from the google as I registered in google developer console .

But I unable to get contacts from yahoo while redirecting to app and I registered in yahoo developers and given redirection url where It has been redirecting without any data as below,

/callback?oauth_token=qvufcvp&oauth_verifier=hp9knk

Please help me, Is there any wrong I did?

Thanks in advance.

Unable to fetch contacts from gmail with version 0.3.1 (trying to parse xml as json)

I have upgraded from version 0.2.2 to 0.3.1 and in the callback I am getting the following:

The error thrown is this:

JSON::ParserError at /google_callback
757: unexpected token at '<?xml version='1.0' encoding='UTF-8'?><feed...[more xml here]

In the trace, in omnicontacts-0.3.1/lib/omnicontacts/importer/gmail.rb l.36, the variable response_as_json is the response, but as xml. So maybe the request sent to gmail does not specify that the result must be as json... How to force the response from gmail to be json ?

I don't know how to troubleshoot further.

Any suggestions ?

Unable to find importer for facebook

Hey Guys,

I have tried using latest version of omnicontacts 0.2.5, I have tried to import contacts for facebook, but when i define importer in config/initializer/omnicontacts.rb. It gives error "Could not find importer facebook"

Then, I looked into the gem, i see there is no importer for facebook.

Please guide me.

URI mismatch error from Gmail

I am getting this
Error :The redirect URI in the request: http://example.com/contacts/gmail/callback did not match a registered redirect URI

But from my computer or credential I am able to access the email this error only showing when I am testing on other computer.

I use "/contacts/gmail/callback" as callback URL and also add this in my routes.rb file

Please help me.

Thanks in advance.
Salayhin

Getting undefined method `include?' for nil:NilClass

Seems to be related to rack 1.4 support. From the current OmniAuth code it appears that line 26 of builder.rb should be:

@ins << @app unless rack14? || @ins.include?(@app)

Going to test and if all looks good will submit a pull request.

Thanks

Internal Server Error uninitialized constant ContactsList

i'm able to get the response from the site but not able to rout to my page and getting routing errors

uninitialized constant ContactsLists
or
uninitialized constant ContactsListsController

config files are below
initilizers/omnicontacts.rb

Rails.application.middleware.use OmniContacts::Builder do
importer :gmail, "client_id", "client_secret", {:redirect_path => "/contact_callback"}

end
in google console

Redirect URI is set to http://localhost:3000/contact_callback

and i want to route the data to my contact_list controller and invite method so in routes i have defined

match "contact_callback" => '/contacts_lists/invitenew'

and i'm getting

http://localhost:3000/contact_callback?code=4/jGYoPAYuZiuW5uR2UjDPmqF6Hjtj.4oxoCiD-BVUQXE-sT2ZLcbShVA5nhwI

let me know what i'm doing wrong.

thanks

How would this gem be modified to accept 'simple search queries' using q?

I had to add an extra parameter to the 'fetch_contacts_using_access_token' in the gmail.rb importer file to accept an additional 'contacts_req_params' like this:

def contacts_req_params
{ "q" => @contact_name.to_s, "max-results" => @max_results.to_s }
end

This causes an error message in the console, 'This services does not support the q parameter', which should be allowed according to the API docs. Any advice/input on how to extend the functionality to accept string parameters would be awesome. Thanks!

v0.3.4 TypeError: no implicit conversion of String into Integer gmail.rb:64

Looks like this is not the code that is in the latest master branch. Can you update rubygems.org?

Thanks

TypeError: no implicit conversion of String into Integer

/vendor/bundle/ruby/2.0.0/gems/omnicontacts-0.3.4/lib/omnicontacts/importer/gmail.rb:64 in "[]"
/vendor/bundle/ruby/2.0.0/gems/omnicontacts-0.3.4/lib/omnicontacts/importer/gmail.rb:64 in "block in contacts_from_response"
/vendor/bundle/ruby/2.0.0/gems/omnicontacts-0.3.4/lib/omnicontacts/importer/gmail.rb:41 in "each"
/vendor/bundle/ruby/2.0.0/gems/omnicontacts-0.3.4/lib/omnicontacts/importer/gmail.rb:41 in "contacts_from_response"
/vendor/bundle/ruby/2.0.0/gems/omnicontacts-0.3.4/lib/omnicontacts/importer/gmail.rb:24 in "fetch_contacts_using_access_token"
/vendor/bundle/ruby/2.0.0/gems/omnicontacts-0.3.4/lib/omnicontacts/middleware/oauth2.rb:52 in "fetch_contacts"
/vendor/bundle/ruby/2.0.0/gems/omnicontacts-0.3.4/lib/omnicontacts/middleware/base_oauth.rb:66 in "block in handle_callback"
/vendor/bundle/ruby/2.0.0/gems/omnicontacts-0.3.4/lib/omnicontacts/middleware/base_oauth.rb:76 in "execute_and_rescue_exceptions"
/vendor/bundle/ruby/2.0.0/gems/omnicontacts-0.3.4/lib/omnicontacts/middleware/base_oauth.rb:62 in "handle_callback"
/vendor/bundle/ruby/2.0.0/gems/omnicontacts-0.3.4/lib/omnicontacts/middleware/base_oauth.rb:39 in "call"
/vendor/bundle/ruby/2.0.0/gems/omnicontacts-0.3.4/lib/omnicontacts/builder.rb:27 in "call"
/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.6.8.164/lib/new_relic/rack/error_collector.rb:43 in "call"
/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.6.8.164/lib/new_relic/rack/agent_hooks.rb:22 in "call"
/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.6.8.164/lib/new_relic/rack/browser_monitoring.rb:16 in "call"
/vendor/bundle/ruby/2.0.0/gems/hirefireapp-0.2.0/lib/hirefireapp/middleware.rb:27 in "call"
/vendor/bundle/ruby/2.0.0/gems/sass-3.2.12/lib/sass/plugin/rack.rb:54 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13.rc2/lib/action_dispatch/middleware/best_standards_support.rb:17 in "call"
/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/etag.rb:23 in "call"
/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/conditionalget.rb:25 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13.rc2/lib/action_dispatch/middleware/head.rb:14 in "call"
/vendor/bundle/ruby/2.0.0/gems/remotipart-1.2.1/lib/remotipart/middleware.rb:27 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13.rc2/lib/action_dispatch/middleware/params_parser.rb:21 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13.rc2/lib/action_dispatch/middleware/flash.rb:242 in "call"
/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210 in "context"
/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13.rc2/lib/action_dispatch/middleware/cookies.rb:341 in "call"
/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13.rc2/lib/active_record/query_cache.rb:64 in "call"
/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13.rc2/lib/active_record/connection_adapters/abstract/connection_pool.rb:479 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13.rc2/lib/action_dispatch/middleware/callbacks.rb:28 in "block in call"
/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13.rc2/lib/active_support/callbacks.rb:405 in "_run__4304472764325038590__call__1715657587715444291__callbacks"
/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13.rc2/lib/active_support/callbacks.rb:405 in "__run_callback"
/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13.rc2/lib/active_support/callbacks.rb:385 in "_run_call_callbacks"
/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13.rc2/lib/active_support/callbacks.rb:81 in "run_callbacks"
/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13.rc2/lib/action_dispatch/middleware/callbacks.rb:27 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13.rc2/lib/action_dispatch/middleware/remote_ip.rb:31 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13.rc2/lib/action_dispatch/middleware/debug_exceptions.rb:16 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13.rc2/lib/action_dispatch/middleware/show_exceptions.rb:56 in "call"
/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13.rc2/lib/rails/rack/logger.rb:32 in "call_app"
/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13.rc2/lib/rails/rack/logger.rb:16 in "block in call"
/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13.rc2/lib/active_support/tagged_logging.rb:22 in "tagged"
/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13.rc2/lib/rails/rack/logger.rb:16 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13.rc2/lib/action_dispatch/middleware/request_id.rb:22 in "call"
/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/methodoverride.rb:21 in "call"
/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/runtime.rb:17 in "call"
/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13.rc2/lib/active_support/cache/strategy/local_cache.rb:72 in "call"
/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/lock.rb:15 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.13.rc2/lib/action_dispatch/middleware/static.rb:63 in "call"
/vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:136 in "forward"
/vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:245 in "fetch"
/vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:185 in "lookup"
/vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:66 in "call!"
/vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:51 in "call"
/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13.rc2/lib/rails/engine.rb:479 in "call"
/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13.rc2/lib/rails/application.rb:223 in "call"
/vendor/bundle/ruby/2.0.0/gems/railties-3.2.13.rc2/lib/rails/railtie/configurable.rb:30 in "method_missing"
/vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/deflater.rb:13 in "call"
/vendor/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:552 in "process_client"
/vendor/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:632 in "worker_loop"
/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.6.8.164/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb:22 in "call"
/vendor/bundle/ruby/2.0.0/gems/newrelic_rpm-3.6.8.164/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb:22 in "block (4 levels) in <top (required)>"
/vendor/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:500 in "spawn_missing_workers"
/vendor/bundle/ruby/2.0.0/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:142 in "start"
/vendor/bundle/ruby/2.0.0/gems/unicorn-4.6.3/bin/unicorn:126 in "<top (required)>"
/vendor/bundle/ruby/2.0.0/bin/unicorn:23 in "load"
/vendor/bundle/ruby/2.0.0/bin/unicorn:23 in "<main>"

Linkedin Support

Can we please have support for linkedin as well to import the address book?

undefined method use_ssl when contacting to google

I'm obtaining the following error when contacting to google.
NoMethodError (undefined method `use_ssl=' for #<Net::HTTP accounts.google.com:443 open=false>):

Full stack trace:

omnicontacts (0.2.3) lib/omnicontacts/http_utils.rb:84:in https_connection' omnicontacts (0.2.3) lib/omnicontacts/http_utils.rb:69:inhttps_post'
omnicontacts (0.2.3) lib/omnicontacts/authorization/oauth2.rb:43:in fetch_access_token' omnicontacts (0.2.3) lib/omnicontacts/middleware/oauth2.rb:50:infetch_contacts'
omnicontacts (0.2.3) lib/omnicontacts/middleware/base_oauth.rb:66:in handle_callback' omnicontacts (0.2.3) lib/omnicontacts/middleware/base_oauth.rb:76:inexecute_and_rescue_exceptions'
omnicontacts (0.2.3) lib/omnicontacts/middleware/base_oauth.rb:62:in handle_callback' omnicontacts (0.2.3) lib/omnicontacts/middleware/base_oauth.rb:39:incall'
omnicontacts (0.2.3) lib/omnicontacts/builder.rb:27:in call' warden (1.0.6) lib/warden/manager.rb:35:incall'
warden (1.0.6) lib/warden/manager.rb:34:in catch' warden (1.0.6) lib/warden/manager.rb:34:incall'
actionpack (3.2.9) lib/action_dispatch/middleware/best_standards_support.rb:17:in call' rack (1.4.1) lib/rack/etag.rb:23:incall'
rack (1.4.1) lib/rack/conditionalget.rb:25:in call' actionpack (3.2.9) lib/action_dispatch/middleware/head.rb:14:incall'
actionpack (3.2.9) lib/action_dispatch/middleware/params_parser.rb:21:in call' actionpack (3.2.9) lib/action_dispatch/middleware/flash.rb:242:incall'
rack (1.4.1) lib/rack/session/abstract/id.rb:205:in context' rack (1.4.1) lib/rack/session/abstract/id.rb:200:incall'
actionpack (3.2.9) lib/action_dispatch/middleware/cookies.rb:341:in call' activerecord (3.2.9) lib/active_record/query_cache.rb:64:incall'
activerecord (3.2.9) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in call' actionpack (3.2.9) lib/action_dispatch/middleware/callbacks.rb:28:incall'
activesupport (3.2.9) lib/active_support/callbacks.rb:405:in _run__84874920__call__4__callbacks' activesupport (3.2.9) lib/active_support/callbacks.rb:405:insend'
activesupport (3.2.9) lib/active_support/callbacks.rb:405:in __run_callback' activesupport (3.2.9) lib/active_support/callbacks.rb:385:in_run_call_callbacks'
activesupport (3.2.9) lib/active_support/callbacks.rb:81:in send' activesupport (3.2.9) lib/active_support/callbacks.rb:81:inrun_callbacks'
actionpack (3.2.9) lib/action_dispatch/middleware/callbacks.rb:27:in call' actionpack (3.2.9) lib/action_dispatch/middleware/reloader.rb:65:incall'
actionpack (3.2.9) lib/action_dispatch/middleware/remote_ip.rb:31:in call' actionpack (3.2.9) lib/action_dispatch/middleware/debug_exceptions.rb:16:incall'
actionpack (3.2.9) lib/action_dispatch/middleware/show_exceptions.rb:56:in call' railties (3.2.9) lib/rails/rack/logger.rb:32:incall_app'
railties (3.2.9) lib/rails/rack/logger.rb:16:in call' activesupport (3.2.9) lib/active_support/tagged_logging.rb:22:intagged'
railties (3.2.9) lib/rails/rack/logger.rb:16:in call' actionpack (3.2.9) lib/action_dispatch/middleware/request_id.rb:22:incall'
rack (1.4.1) lib/rack/methodoverride.rb:21:in call' rack (1.4.1) lib/rack/runtime.rb:17:incall'
activesupport (3.2.9) lib/active_support/cache/strategy/local_cache.rb:72:in call' rack (1.4.1) lib/rack/lock.rb:15:incall'
actionpack (3.2.9) lib/action_dispatch/middleware/static.rb:62:in call' railties (3.2.9) lib/rails/engine.rb:479:incall'
railties (3.2.9) lib/rails/application.rb:223:in call' rack (1.4.1) lib/rack/content_length.rb:14:incall'
railties (3.2.9) lib/rails/rack/log_tailer.rb:17:in call' rack (1.4.1) lib/rack/handler/webrick.rb:59:inservice'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in service' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:inrun'
/usr/lib/ruby/1.8/webrick/server.rb:173:in start_thread' /usr/lib/ruby/1.8/webrick/server.rb:162:instart'
/usr/lib/ruby/1.8/webrick/server.rb:162:in start_thread' /usr/lib/ruby/1.8/webrick/server.rb:95:instart'
/usr/lib/ruby/1.8/webrick/server.rb:92:in each' /usr/lib/ruby/1.8/webrick/server.rb:92:instart'
/usr/lib/ruby/1.8/webrick/server.rb:23:in start' /usr/lib/ruby/1.8/webrick/server.rb:82:instart'
rack (1.4.1) lib/rack/handler/webrick.rb:13:in run' rack (1.4.1) lib/rack/server.rb:265:instart'
railties (3.2.9) lib/rails/commands/server.rb:70:in start' railties (3.2.9) lib/rails/commands.rb:55 railties (3.2.9) lib/rails/commands.rb:50:intap'
railties (3.2.9) lib/rails/commands.rb:50
script/rails:6:in `require'
script/rails:6

SocketError getaddrinfo: Hôte inconnu. on callback

Hi,

Once the user clicks on the gmail link (havent started tested the others yet), I go to google and on the callback i get this error:

Started POST "/contacts/gmail" for 127.0.0.1 at 2012-03-28 14:34:16 +0200

Started GET "/oauth2callback?code=4/JRqeE4JhdgYeqOtDesifrYFJ7FFY" for 127.0.0.1 at 2012-03-28 14:34:20 +0200

SocketError (getaddrinfo: H�te inconnu. ):

I'm running on localhost. Hôte Inconnu = unknown host in french :)

request.env['omnicontacts.user'] is empty

request.env['omnicontacts.user'] has no value when authenticating with a Google account. Is this just me having this issue? request.env['omnicontacts.contacts'] works as expected.

Invalid_client error with gmail contacts oauth

Hi! First of all, thanks for the gem!

I think this requires a simple fix, but not sure where to look/see since it looks like I have everything correctly....

I have a link to [my_domain]/contacts/gmail on a test page. When I click on the link, I get the following error. I double-checked OAuth Key and Secret, and they are correct.

Error: invalid_client
Request Details
scope=https://www.google.com/m8/feeds
response_type=code
access_type=online
redirect_uri=http://[my_domain]/contacts/gmail/callback
approval_prompt=auto
client_id=[OAuth Consumer Key]

Any help would be much appreciated!

Thanks.

Contacts returned from Gmail has emails with the contact's name and a | char

I've been using omnicontacts in our production environment for nearly a year now (still on version 0.2.2!) and I haven't had any problems. However, in a recent import (around 1 month ago) from Gmail for one particular user returned 900 contacts, where all contacts had the email field formatted with 'FIRST_NAME LAST_NAME|[email protected]'. So for example, one email field would be "John Chow|[email protected]".

I'm not sure if anyone has seen this issue before, and while it only has happened once for all our imports, I just want to double check here before I brush it off as a one time burp from Gmail.

Is it possible to change the Gmail permissions message to user?

Hi All,

Is there a way to adjust the message that Google displays to the user? The problem is that some users might think that the app will edit or delete existing contacts rather than simply making a copy of them. I looked in https://code.google.com/apis/console/ but didn't find a way to adjust the message. Thanks!!

Default Message from Google:
[App Name] is requesting permission to:
Manage your contacts
View and manage your Google Contacts

Windows Live API is useless for pulling contacts

I think maybe Hotmail should be removed from the list of supported e-mail services. After spending too much time debugging why omnicontacts was returning an empty array for Hotmail contacts, I realized it's because the API returns this:

{
   "data": [
      {
         "first_name": "John", 
         "last_name": "Doe", 
         "name": "John Doe", 
          <snip>
         "email_hashes": [
            "f37cb083473f0fef7f3b4172ccd2ff6070f3e7ccd1752be79c3a2d7ba40decd5"
         ], 
         "updated_time": "2012-08-01T16:29:17+0000"
      }
   ]
}

So, in other words, you can't ever get a list of e-mail addresses from it.

http://stackoverflow.com/questions/6785828/get-a-users-contacts-email-phone-addresses-using-windows-live-messenger-connec

Hotmail The provided value for the input parameter 'redirect_uri' is not valid. The domain of the provided redirect URI must match the domain of the redirect URI registered for this app.

Hotmail throws an
The provided value for the input parameter 'redirect_uri' is not valid. The domain of the provided redirect URI must match the domain of the redirect URI registered for this app.

I followed all docs and the example app, there should not be a redirect_uri param in the initialiser at hotmail section?

Want to pass username and password with request and want to avoid redirection

Hey, thanks for awesome info and example in readme, i'm able get the contacts now,but now in my site i dont want to redirect and trying to input username and pass with request and get ajax response and display because importing contacts is part of the form and i don't want to reload it. i saw "login_hint" parameter in authorization but it only has username option.i want to login and get contacts in background and get results.
any ideas?

Capturing the Contact's Provider ID

Has anyone forked a solution that tracks the contact id passed by the provider?

For example with hotmail:
{"id":"contact.3dca7e65000000000000000000000011"

Gmail:
http://www.google.com/m8/feeds/contacts/liz%40gmail.com/base/8411573

Yahoo:
"uri": "http://social.yahooapis.com/v1/user/XMCDY3KDAYNPDILERMPN3PHPKU/contact/114"

The idea being that you want to track these ids so that on the next contact import you can find/update/skip through the previously imported records.

Thoughts? Thank

myapp.com/contacts/gmail opens auth window even when not logged in

myapp.com/contacts/gmail creates an open link that opens the oauth screen for a selected provider that cannot be protected behind a login.

I need better way to handle this, currently using devise and in regular controllers you can set it so a users first needs to be logged in.

Is there a way to force this somehow?
This gem is very nice but these things still a bit rough out of the box to use it as production

max contacts for gmail

Question-

How would you want to handle the max number of contacts for Gmail - if it were to be a configurable parameter? Right now it's set to 100 in the importer, but I'm thinking if in the initializer you could pass a parameter like:

importer :gmail, "xxx", "yyy", :max_contacts => 1000

or something like that. Have you given this any thought?

Great gem by the way!

Arun

Rack::Lint::LintError at /contacts/gmail No Content-Type header found

I tried creating a new rails (v3.2.3) application and everything is working fine there. I could fetch the contacts.

But when I tried to implement the same for another rails (v3.0.9) application (using rack v1.2.4), got the error:

Ruby    /media/workspace/ynl/vendor/cache/ruby/1.9.1/gems/rack-1.2.4/lib/rack/lint.rb: in assert, line 19

Can anybody help fixing this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.