Omniouth and facebook and twitter

Ciao a tutti ho integrato facebook e twitter nella mia applicazione;
ho dei errori:

intanto vi elenco i miei file e i miei metodi:

GEMFILE:

gem ‘devise’
gem ‘omniauth’
gem ‘omniauth-twitter’
gem ‘omniauth-facebook’
gem ‘omniauth-linkedin’
gem ‘omniauth-google-oauth2’

FILE: device.rb:

config.omniauth :facebook, “1487929211426782”,
“d5accf751b367521a5b7e9bbf57fa98c”, {:scope => ‘email, read_stream,
read_friendlists, friends_likes, friends_status, offline_access,
publish_stream’, :display => “popup”}
config.omniauth :twitter, “xsVbzW2uFYv7rz4Nc0CWFHRrX”,
“pQ9T2u8EgBPC8DC4AduNagWIlyngpRj2VnD2JK1xSjDZrZ3xmb”, :display =>
“popup”

FILE: OmniauthCallbacksController.rb:

def facebook
@user = User.find_for_facebook_oauth(request.env[“omniauth.auth”],
current_user)
if @user.persisted?
sign_in_and_redirect @user, :event => :authentication #this will
throw if @user is not activated
set_flash_message(:notice, :success, :kind => “Facebook”) if
is_navigational_format?
else
session[“devise.facebook_data”] = request.env[“omniauth.auth”]
redirect_to new_user_registration_url
end
end

def twitter
auth = env[“omniauth.auth”]

@user =

User.find_for_twitter_oauth(request.env[“omniauth.auth”],current_user)
if @user.persisted?
flash[:notice] = I18n.t “devise.omniauth_callbacks.success”
sign_in_and_redirect @user, :event => :authentication
else
session[“devise.twitter_uid”] = request.env[“omniauth.auth”]
redirect_to new_user_registration_url
end
end

FILE user.rb:

def self.find_for_facebook_oauth(auth, signed_in_resource=nil)
user = User.where(:provider => auth.provider, :uid =>
auth.uid).first
if user
return user
else
registered_user = User.where(:email => auth.info.email).first
if registered_user
return registered_user
else
user = User.create(name:auth.extra.raw_info.name,
provider:auth.provider,
uid:auth.uid,
email:auth.info.email,
password:Devise.friendly_token[0,20],
)
end end
end

def self.find_for_twitter_oauth(auth, signed_in_resource=nil)
user = User.where(:provider => auth.provider, :uid =>
auth.uid).first
if user
return user
else
registered_user = User.where(:email => auth.uid +
"@twitter.com").first
if registered_user
return registered_user
else

    user = User.create(name:auth.extra.raw_info.name,
                       provider:auth.provider,
                       uid:auth.uid,
                       email:auth.uid+"@twitter.com",
                       encrypted_password:Devise.friendly_token[0,20],
    )
  end

end

end

una volta effettuato questo noto che sulla view di device sign in
automaticamente ha inserito due link per effetuare il login con facebook
e twitter;

Bene provo il login con facebook inanzitutto la cosa che noto è che ci
impiega tantissimo molto molto lento, alcune volte mi da anche errore:

SSL_connect returned=1 errno=0 state=unknown state: unknown protocol

Quando provo con twitter stessa cosa tempo di attesa molto lungo, e
alcune volte mi da errore sui coockie altre nn mi fa nulla.

cosa potrebbe essere???

Qual’ l’indirizzo di callback inserito su Facebook?

Alessandro R.

On Fri, Apr 4, 2014 at 11:36 AM, Roberto S. <

http://localhost:8080/

da un po di tempo ricevo quest’altro messaggio:
OAuth2::Error

{“message”=>“(#5) Unauthorized source IP address”,
“type”=>“OAuthException”, “code”=>5}:
{“error”:{“message”:“(#5) Unauthorized source IP
address”,“type”:“OAuthException”,“code”:5}}