title: Rails API Omniauth (Facebook) Login
body: <p>I have a Rails API which is stateless, with Devise gem for authentication and using Devise generated <code>auth_token</code> to authorise each request. Now I want to add login via Facebook with following flow:</p>
  
  <ol>
  <li>User authorise the Facebook app to get required data.</li>
  <li>Redirect to certain page according to Facebook settings (<code>/auth/facebook/callbacks</code>).</li>
  <li>Get or create user (if not registered yet).</li>
  <li>Redirect to previous page (before we click <em>login with facebook</em>) <strong>with <code>auth_token</code>.</strong></li>
  </ol>
  
  <p>The problem is in step 4, how do I get the <code>auth_token</code> via json after redirect. Anyway, the auth_token is generated each time user created or signed in successfully (via email &amp; password).</p>
  
  <p>Any best example for this?</p>
  
  <p>Thanks</p>