Skip to main content

Subscribe to GoRails to get access to this episode and all other pro episodes, and new awesome content every month.

Subscribe Now
Only $19/month

Unlimited access. Cancel anytime.

19 Login with Facebook

Episode 199 · July 24, 2017

Learn how to add Facebook login via OAuth using Omniauth

Authentication


Transcripts

Subscribe or login to view the transcript for this episode.

Discussion


Gravatar
Andrew Porter on

Thanks for the video—it was great! I would love to see how you'd approach managing multiple OmniAuth strategies for a single user without Devise.…


Gravatar
Rama Astadipati on

Resource link replay video.
Thanks for great tutorial.

Gravatar
Chris Oliver (159,840 XP) on

Fixed!


Gravatar
James Shepherd (600 XP) on

Wow, awesome episode Chris, very useful as always.


Gravatar
Taeyang Lee (210 XP) on

Thanks for the awesome tutorial.
In fb oauth, we are given an email address. But some platforms does not give an email address.
What is the best way to handle this case? I am trying to redirect a page where user can put their email address and save it. Could you please give me a guideline for this?

Gravatar
Chris Oliver (159,840 XP) on

That would make for a good episode. I'll add this to my list. Luckily most of them, even Twitter, now provide email address.

The rough idea is that you should save the omniauth auth info to a cookie, and then redirect the user to set their email and save it all together.


Gravatar
Dan Frenette on

So I followed the tutorial to the letter but kept getting this error when trying to authenticate:

`Could not authenticate you from Facebook because "Invalid credentials".`

Of course everything was copy pasted directly from the facebook developer screen so the credentials were correct. 45 minutes deep into stack overflow and I discovered that pasting this into my devise.rb (as a parameter after the app secret, before the scope) made things work.

`token_params: { parse: :json }`

Hope this helps anyone who's stuck, or maybe someone can tell me what I did wrong

Also fantastic episode Chris! Couldn't have gotten this far without this!


Gravatar
Pardha (3,110 XP) on

If we have an existing user in our application and he would like to login through Facebook having the same email address then this code breaks as the user was already exists with same email address in our Users table .

Gravatar
Chris Oliver (159,840 XP) on

Watch the next episode in the series: https://gorails.com/episode...


Login or create an account to join the conversation.