Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9132497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:19:15+00:00 2026-06-17T08:19:15+00:00

Our Rails 3 app uses facebook-omniauth, allowing users to authenticate with facebook. It’d be

  • 0

Our Rails 3 app uses facebook-omniauth, allowing users to authenticate with facebook.

It’d be nice to use as much of the web based authentication system as possible, so I tried following the answer (the one that hasn’t been down-voted) to this SO question but I can’t get it to work.

The gist of the answer is:

omniauth-facebook will handle requests to the callback endpoint with an access_token parameter without any trouble. Easy 🙂

So to test this, in my browser I’m issuing the following request:

/users/auth/facebook_api/callback?access_token=BAAB...

But in my server log, I see:

(facebook) Callback phase initiated.
(facebook) Authentication failure! invalid_credentials: OAuth2::Error, : 
{"error":{"message":"Missing authorization code","type":"OAuthException","code":1}}

I can’t figure out what I’m doing wrong. Is the fact that I’m trying to do this through the browser to test messing something up? Any other ideas on how I can reuse my www based auth logic for my ios app?

UPDATE:
I’m not sure, but I’m following this guide in order to have multiple facebook omniauth strategies, one for www and another for mobile.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:19:16+00:00Added an answer on June 17, 2026 at 8:19 am

    I never found a solution in line with what I was asking originally, but here is how I solved it: Take the access token you get on the iPhone and send it up to your server and perform the login manually.

    def facebook_login
      graph = Koala::Facebook::API.new(params[:user][:fb_access_token])
      profile = graph.get_object('me')
      omniauth = build_omniauth_hash(profile)
    
      @user = User.find_or_create_for_facebook_oauth(omniauth)
    end
    

    On www we already had a method called find_or_create_for_facebook_oauth, and that took the result from Omniauth and either found the user or created a new one. In order to utilize that method for mobile, I had to build up a similar structure by hand so I could pass it as an argument.

    def build_omniauth_hash(profile)
      struct = OpenStruct.new
      struct.uid = profile['id']
      struct.info = OpenStruct.new
      struct.info.email = profile['email']
      struct.info.image = "http://graph.facebook.com/#{profile['id']}/picture?type=square"
      struct.info.first_name = profile['first_name']
      struct.info.last_name = profile['last_name']
      struct.info.bio = profile['bio']
      struct.info.hometown = profile['hometown']['name'] if profile['hometown']
      struct.info.location = profile['location']['name'] if profile['location']
      struct
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some of the users of our Ruby on Rails app have complained that page
our rails web app has to download/unpack archives with html pages from ftp on
Users of my Rails app can authenticate in one of these 2 manners: Using
Our app uses Rails.cache in the controller to cache some items outside the scope
I'm starting to integrate our Rails-based app with other, external APIs. We're going to
In our Rails app that runs in Facebook canvas, we have a workflow where
We use the wonderful semantic versioning paradigm when versioning our rails app. One question
We are using octopus in our rails app to forward read queries directly to
We are getting close to releasing our new rails app and so far interest
I'm looking into database backup options for our Heroku rails app, and it looks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.