Omniauth for rails and ios authentication

I have a rails application that processes api for an iOS client. I am using devus, omniauth-facebook for rails. for the iOS client, I use accounts and social frameworks for facebook authentication. I grabbed the oauth token and passed it to the rails via the omniauth callback for authentication, but I got this error. Can someone please guide me on what I am doing wrong? Below is the magazine that I get.

Started POST "/users/auth/facebook/callback" for ::1 at 2015-01-12 10:59:22 +0800 I, [2015-01-12T10:59:22.928323 #99294] INFO -- omniauth: (facebook) Callback phase initiated. E, [2015-01-12T10:59:22.929737 #99294] ERROR -- omniauth: (facebook) Authentication failure! no_authorization_code: OmniAuth::Strategies::Facebook::NoAuthorizationCodeError, must pass either a code (via URL or by an fbsr_XXX signed request cookie) Processing by Users::OmniauthCallbacksController#failure as / Parameters: {"access_token"=>"tokenFromACFBiOS"} Redirected to localhost:3000/users/sign_in Completed 302 Found in 4ms (ActiveRecord: 0.0ms) 

Here is the gist of my iOS and backend code. https://gist.github.com/chocnut/ae6f415accd95c8ef415

+8
ios ruby-on-rails facebook devise omniauth-facebook
source share
2 answers

I was able to achieve this using Gem. https://github.com/SoapSeller/omniauth-facebook-access-token

Create another oauth provider in the initializer of your project called facebook_access_token, it can use the same credentials as the facebook provider.

Put the token as the "access_token" parameter. Use a query string? Format = json in the callback url if you want the final response from your application to be returned as JSON.

0
source share

When you create a facebook (fb) application, you must indicate where the URL callback is located, maybe you set it to fb as: http://localhost:3000/bla/bla It works fine if you are testing on your own machine but in order to be able to test on your ios device then you must change localhost to something like your ip device (example 192.168.1.1)

-one
source share

All Articles