Re: Facebook Authentication

157 views
Skip to first unread message

Andreas Ronge

unread,
Mar 10, 2011, 3:13:27 AM3/10/11
to neo...@googlegroups.com
I've not tried. How far have you come ? What's the problem ?


On Thu, Mar 10, 2011 at 4:58 AM, whyhellothere <jose....@gmail.com> wrote:
> anyone out there able to get a Facebook Authentication to work on
> Neo4j.rb ?
>
> --
> You received this message because you are subscribed to the Google Groups "neo4jrb" group.
> To post to this group, send email to neo...@googlegroups.com.
> To unsubscribe from this group, send email to neo4jrb+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/neo4jrb?hl=en.
>
>

Oliver Bruening

unread,
Mar 10, 2011, 3:41:45 AM3/10/11
to neo...@googlegroups.com
take a look at http://railscasts.com/episodes/241-simple-omniauth

this is most likely the easiest way to connect to facebook with rails. the example is for twitter, but works the same way for facebook.

--- Andreas Ronge <andrea...@gmail.com> schrieb am Do, 10.3.2011:

Oliver Bruening

unread,
Mar 12, 2011, 9:46:42 AM3/12/11
to neo...@googlegroups.com
be sure that yout users table has a provider field and a uid field. rails contructs these find methods from the columns of your tables.

--- whyhellothere <jose....@gmail.com> schrieb am Sa, 12.3.2011:

> Von: whyhellothere <jose....@gmail.com>
> Betreff: Re: Facebook Authentication

> An: "neo4jrb" <neo...@googlegroups.com>
> Datum: Samstag, 12. März, 2011 13:23 Uhr
> it causes the exception :
>
>   undefined method `find_by_provider_and_uid' for
> User:Class
>
>
>
> On Mar 12, 4:40 am, whyhellothere <jose.vi...@gmail.com>
> wrote:
> > http://railscasts.com/episodes/241-simple-omniauth
> >
> > woops, spoke too soon ..
> > the callback proceeds ok, but i'm having trouble with
> :
> >
> >   # sessions_controller.rb
> >     user =
> User.find_by_provider_and_uid(auth["provider"],
> > auth["uid"]) || User.create_with_omniauth(auth)
> >
> > also, when i temporarily remove the first part and
> just
> > create_with_omniauth ..
> > it doesn't seem to get any information out of the auth
> ..
> > tips & suggestions greatly appreciated
> >
> > On Mar 10, 7:18 pm, whyhellothere <jose.vi...@gmail.com>
> wrote:
> >
> >
> >
> > > nice, that was relatively painless .. and it
> found the jruby-openssl
> > > gem this time around
> >
> > > THANK YOU !!
> >
> > > On Mar 10, 1:41 am, whyhellothere <jose.vi...@gmail.com>
> wrote:
> >
> > > > thanks,
> > > > was considering giving
> authlogic_facebook_connect a try,
> > > > but will try that first
> >
> > > > On Mar 10, 12:41 am, Oliver Bruening <obruen...@yahoo.com>
> wrote:
> >
> > > > > take a look athttp://railscasts.com/episodes/241-simple-omniauth


> >
> > > > > this is most likely the easiest way to
> connect to facebook with rails. the example is for twitter,
> but works the same way for facebook.
> >

> > > > > --- Andreas Ronge <andreas.ro...@gmail.com>
> schrieb am Do, 10.3.2011:


> >
> > > > > > Von: Andreas Ronge <andreas.ro...@gmail.com>
> > > > > > Betreff: Re: Facebook
> Authentication
> > > > > > An: neo...@googlegroups.com
> > > > > > Datum: Donnerstag, 10. März, 2011
> 08:13 Uhr
> > > > > > I've not tried. How far have you
> come
> > > > > > ? What's the problem ?
> >
> > > > > > On Thu, Mar 10, 2011 at 4:58 AM,

> whyhellothere <jose.vi...@gmail.com>


> > > > > > wrote:
> > > > > > > anyone out there able to get
> a Facebook Authentication
> > > > > > to work on
> > > > > > > Neo4j.rb ?
> >
> > > > > > > --
> > > > > > > You received this message
> because you are subscribed
> > > > > > to the Google Groups "neo4jrb"
> group.
> > > > > > > To post to this group, send
> email to neo...@googlegroups.com.
> > > > > > > To unsubscribe from this
> group, send email to
> > > > > > neo4jrb+u...@googlegroups.com.
> > > > > > > For more options, visit this

> group athttp://groups.google.com/group/neo4jrb?hl=en.


> >
> > > > > > --
> > > > > > You received this message because
> you are subscribed to the
> > > > > > Google Groups "neo4jrb" group.
> > > > > > To post to this group, send email
> to neo...@googlegroups.com.
> > > > > > To unsubscribe from this group,
> send email to neo4jrb+u...@googlegroups.com.
> > > > > > For more options, visit this group

> athttp://groups.google.com/group/neo4jrb?hl=en.

Andreas Ronge

unread,
Mar 12, 2011, 9:48:28 AM3/12/11
to neo...@googlegroups.com
I guess only find_by_x works and not find_by_x_and_y
Should be very easy to impl if this is missing in neo4j.rb


On Sat, Mar 12, 2011 at 2:23 PM, whyhellothere <jose....@gmail.com> wrote:
> it causes the exception :
>
>  undefined method `find_by_provider_and_uid' for User:Class
>
>
>
> On Mar 12, 4:40 am, whyhellothere <jose.vi...@gmail.com> wrote:
>> http://railscasts.com/episodes/241-simple-omniauth
>>
>> woops, spoke too soon ..
>> the callback proceeds ok, but i'm having trouble with :
>>
>>   # sessions_controller.rb
>>     user = User.find_by_provider_and_uid(auth["provider"],
>> auth["uid"]) || User.create_with_omniauth(auth)
>>
>> also, when i temporarily remove the first part and just
>> create_with_omniauth ..
>> it doesn't seem to get any information out of the auth ..
>> tips & suggestions greatly appreciated
>>
>> On Mar 10, 7:18 pm, whyhellothere <jose.vi...@gmail.com> wrote:
>>
>>
>>
>> > nice, that was relatively painless .. and it found the jruby-openssl
>> > gem this time around
>>
>> > THANK YOU !!
>>
>> > On Mar 10, 1:41 am, whyhellothere <jose.vi...@gmail.com> wrote:
>>
>> > > thanks,
>> > > was considering giving authlogic_facebook_connect a try,
>> > > but will try that first
>>
>> > > On Mar 10, 12:41 am, Oliver Bruening <obruen...@yahoo.com> wrote:
>>

>> > > > take a look athttp://railscasts.com/episodes/241-simple-omniauth


>>
>> > > > this is most likely the easiest way to connect to facebook with rails. the example is for twitter, but works the same way for facebook.
>>

>> > > > --- Andreas Ronge <andreas.ro...@gmail.com> schrieb am Do, 10.3.2011:


>>
>> > > > > Von: Andreas Ronge <andreas.ro...@gmail.com>
>> > > > > Betreff: Re: Facebook Authentication
>> > > > > An: neo...@googlegroups.com
>> > > > > Datum: Donnerstag, 10. März, 2011 08:13 Uhr
>> > > > > I've not tried. How far have you come
>> > > > > ? What's the problem ?
>>

>> > > > > On Thu, Mar 10, 2011 at 4:58 AM, whyhellothere <jose.vi...@gmail.com>


>> > > > > wrote:
>> > > > > > anyone out there able to get a Facebook Authentication
>> > > > > to work on
>> > > > > > Neo4j.rb ?
>>
>> > > > > > --
>> > > > > > You received this message because you are subscribed
>> > > > > to the Google Groups "neo4jrb" group.
>> > > > > > To post to this group, send email to neo...@googlegroups.com.
>> > > > > > To unsubscribe from this group, send email to
>> > > > > neo4jrb+u...@googlegroups.com.

>> > > > > > For more options, visit this group athttp://groups.google.com/group/neo4jrb?hl=en.


>>
>> > > > > --
>> > > > > You received this message because you are subscribed to the
>> > > > > Google Groups "neo4jrb" group.
>> > > > > To post to this group, send email to neo...@googlegroups.com.
>> > > > > To unsubscribe from this group, send email to neo4jrb+u...@googlegroups.com.

>> > > > > For more options, visit this group athttp://groups.google.com/group/neo4jrb?hl=en.

Andreas Ronge

unread,
Mar 13, 2011, 9:32:45 AM3/13/11
to neo...@googlegroups.com
Hi

This is because save did not allow a block for initialization, but I
just added support for that on GIT HEAD
check http://neo4j.lighthouseapp.com/projects/15548-neo4j/tickets/162-create-method-should-take-a-block


On Sun, Mar 13, 2011 at 3:24 AM, whyhellothere <jose....@gmail.com> wrote:
>
> yup, the fields are in the model ..
>
> when i comment out find_by_x_and_y and continue with creating a new
> user .. it creates a user entry in the database .. but the fields are
> blank .. still digging around to try and understand why ...
>
>
>
> class SessionsController < ApplicationController
>  def create
>    auth = request.env["omniauth.auth"]
>  # user = User.find_by_provider_and_uid(auth["provider"],
> auth["uid"]) || User.create_with_omniauth(auth)
>    user = User.create_with_omniauth(auth)
>    session[:user_id] = user.id
>    redirect_to root_url, :notice => "Signed in!"
>  end
> end
>
>
>
> class User < Neo4j::Rails::Model
>  property :provider, :type => String
>  property :uid, :type => String
>  property :name, :type => String
>
>  def self.create_with_omniauth(auth)
>    create! do |user|
>      user.provider = auth["provider"]
>      user.uid = auth["uid"]
>      user.name = auth["user_info"]["name"]
>    end
>  end
> end


>
>
>
> On Mar 12, 6:46 am, Oliver Bruening <obruen...@yahoo.com> wrote:
>> be sure that yout users table has a provider field and a uid field. rails contructs these find methods from the columns of your tables.
>>

>> --- whyhellothere <jose.vi...@gmail.com> schrieb am Sa, 12.3.2011:

>> > For more options, visit this group athttp://groups.google.com/group/neo4jrb?hl=en.

kichael

unread,
May 6, 2011, 11:49:42 PM5/6/11
to neo4jrb
Hello,

I just wanted to chime in on my experience with omniauth + neo4j.rb

An issue I ran into, is when trying to find the right authentication,
in my authenticaitons_controller, the query would produce wrong
results.
All the following produced the wrong result as in they would find the
currently existing authentication! and not return nil as expected.
So if I had one twitter authentication already in the db, and I was
searching for provider== facebook, the result would be that twitter
authentication. Super odd.
authentication = current_user.authentications.find{|a| a.provider ==
omniauth['provider'] && a.uid== omniauth['uid'] }
authentication = Authentication.find{|a| a.provider ==
omniauth['provider'] && a.uid== omniauth['uid']}

authentication = Authentication.find("provider:
#{omniauth['provider']} AND uid: #{omniauth['uid']}")
authentication = Authentication.all{|n| n.provider ==
omniauth['provider'] && n.uid == omniauth['uid']}.first

the lucene query always produced nil, likely because the property/uid
are not indexes,
authentication = Authentication.find( :first, :conditions =>
["provider = ? and uid = ?", omniauth['provider'], omniauth['uid']])

The only way I got the correct behavior is by turning the traverser
into an array and doing a find query on it:
authentication = Authentication.all.to_ary.find{|n| n.provider ==
"#{omniauth['provider']}" && n.uid == "#{omniauth['uid']}"}

Hope this helps to anyone trying to implement omniauth in neo4j.rb

Cheers,

Michael Solovyov

On Mar 13, 7:53 am, whyhellothere <jose.vi...@gmail.com> wrote:
> YEAH !  WOOHOOO !!
>
> On Mar 13, 6:32 am, Andreas Ronge <andreas.ro...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi
>
> > This is because save did not allow a block for initialization, but I
> > just added support for that on GIT HEAD
> > checkhttp://neo4j.lighthouseapp.com/projects/15548-neo4j/tickets/162-creat...

andre f

unread,
Mar 1, 2013, 12:29:58 AM3/1/13
to neo...@googlegroups.com
Hi All,

New here and getting this message thread back from the grave.

Has anyone managed to solve this on a elegant fashion? If yes, could provide some guidance on workable code?

Thanks

chris fitzpatrick

unread,
Mar 1, 2013, 5:06:56 AM3/1/13
to neo...@googlegroups.com

Hey Andre,

Sure...check out this demo I just threw together: https://github.com/cfitz/neo4j-facebook-demo

This uses devise and the devise-neo4j gem i forked. It's pretty straight forward, if you're familiar with Devise/Omniauth
Let me know if you have any questions...

b,chris.

March 1, 2013 6:29 AM
Hi All,

New here and getting this message thread back from the grave.

Has anyone managed to solve this on a elegant fashion? If yes, could provide some guidance on workable code?

Thanks


On Thursday, March 10, 2011 2:58:00 PM UTC+11, wyhelother wrote:
--
You received this message because you are subscribed to the Google Groups "neo4jrb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4jrb+u...@googlegroups.com.

To post to this group, send email to neo...@googlegroups.com.

Andreas Ronge

unread,
Mar 1, 2013, 6:41:36 AM3/1/13
to neo...@googlegroups.com

andre f

unread,
Mar 2, 2013, 9:54:17 PM3/2/13
to neo...@googlegroups.com
Chris,

Great stuff. Quite clean and easy to grasp. Small caveat: Seems like you accidentally left a backdoor on it. ;-)

Cheers
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages