Fernando
Fernando

Reputation: 325

Devise with Facebook Omniauth - How to authenticate using API?

I have an application running Rails 4, Devise and Omniauth (Facebook). Everything works fine.

Now I want to create an IOS app to access this database. I planned to do this using JSON requests to fetch and post data to Rails RESTfull resources that I have.

Before I start writing the IOS app, I tried to test retrieving data from the web app, using cURL on command line (JSON requests), but Devise always reject me saying that I have to authenticate first.

How should I do this? How to authenticate, using JSON requests, using Facebook username/password and access the data from the Rails app?

Or am I thinking all wrong and I should do this in a different way?

Upvotes: 2

Views: 784

Answers (1)

Viktor Leonets
Viktor Leonets

Reputation: 473

  1. You must create Facebook APP
  2. You have to use Facebook SDK for login in Facebook
  3. In the app using SDK you have to make login in the facebook
  4. After a successful login facebook return "access token" for api requests.
  5. "access token" you must send on the server with ruby on rails.
  6. You have to use gem "koala" or other for access to facebook api using this "access token".' 6.1 As first step you must get user information from facebook. (you will have facebook UID, and may be email.) 6.2 Then you must find current user in your DB and login using Devise method sign_in

Also you have to seen this gem https://github.com/lynndylanhurley/devise_token_auth

Upvotes: 2

Related Questions