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

  • SEARCH
  • Home
  • 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 6094305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:39:43+00:00 2026-05-23T12:39:43+00:00

I have a Rails web service running with Devise + OmniAuth. I have users

  • 0

I have a Rails web service running with Devise + OmniAuth. I have users authenticating against Facebook Connect on a mobile device. I then want the mobile device to establish a session with our web services. What do I need to pass to device from the mobile client to establish this session? Is there a code sample on the Rails side of things of how to handle this id+token that is passed from facebook -> mobile -> web service?

  • 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-05-23T12:39:44+00:00Added an answer on May 23, 2026 at 12:39 pm

    I have not found a good way of doing this. I am not using :omniauthable either, I’m using OmniAuth and Devise separately as seen in the Railscast episode where there are two tables users and authentications. It’s kinda hacky and only works for Facebook.

    Basically, send your access_token from the iPhone to the server over SSL, or something similar. You have to check with OmniAuth first and if you are granted access, then you can manually create a session with OmniAuth by going something like:

    I did get something to work by doing this though:

    FB = OmniAuth::Strategies::Facebook.new("nothing") 
    
    client = ::OAuth2::Client.new("nothing", "nothing", FB.client_options) 
    
    cached_token = "app_id_part|session_id_part|token_part" # or maybe you sent it from the iPhone
    access_token = ::OAuth2::AccessToken.new(client, cached_token)  
    
    FB.instance_variable_set("@access_token", access_token) 
    
    FB.auth_hash 
    # You will either get a hash or get this error:
    # OAuth2::AccessDenied: Received HTTP 401 during request.
    

    After that you lookup the user info you need to find the user via your Authentications table:

    @user = Authentication.where(:uid => FB.auth_hash["uid"], :provider => "facebook").first.user
    

    Now we create a session:

    sign_in_and_redirect(:user, @user)
    
    # or, perhaps
    
    sign_in(@user, :bypass => true)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Rails app whose major part is to query another web-service using
I have a Rails application that queries a 3rd party web service. I am
I am using Ruby on Rails to write a web-service. Basically, I have an
I have some Rails web service, and iOS iPad app. This iPad app need
I have implemented web service using rails server. The server uses rails default authentication
I have a Rails RESTful web service application that accepts a value from a
I have a need to have SOAP web service on my rails app. (this
I have never worked with web services and rails, and obviously this is something
The rails books and web pages I've been following have all stuck to very
Do the major web application frameworks (Rails, Django, etc) have libraries that provide functionality

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.