Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to authenticate to Doorkeeper with Facebook login?

I've a rails app where my users can login in it with Devise gem and Omniauth-facebook gem. They can be 'normal' users or facebook users. All of this works correctly.

I've an API in this app authenticate by Doorkeeper too. From my mobile client I can send user and password and they can access to my API with an access_token. This works correctly.

Now, I want that my facebook users will be able to access to my API through theirs facebook login from the mobile app. somebody knows how I could do this? After login with facebook, I will have a token and I will be able to access some information about the user... but how I could connect to API?

Note: When you log in the rails app with facebook, Devise creates a new user with a provider and an uid fields.

any ideas? thanks a lot.

like image 553
user1364684 Avatar asked Mar 28 '14 11:03

user1364684


Video Answer


2 Answers

I think you're looking for this https://github.com/doorkeeper-gem/doorkeeper-grants_assertion

like image 153
Moh Avatar answered Sep 28 '22 18:09

Moh


I was able to achieve this by the following steps:

  1. Retrieving a facebook through the facebook SDK on client side
  2. Expose an API like /facebook/login?facebook_token=XXX
  3. Once i get the facebook_token from the client i used Koala to retrieve user's information(including email) from facebook
  4. Authenticate the user by email
  5. Generate a Doorkeeper::Token for that user and send it back to the client
like image 26
Alberto Pellizzon Avatar answered Sep 28 '22 17:09

Alberto Pellizzon