title: Authenticate user using omniauth and Facebook for a rails API?
body: <p>I'm building a Rails API and have successfully built a way for a user to authenticate using Omniauth Identity.</p>
  
  <p>We simply post to auth/identity/callback from the client, passing in an auth_key and password.<br>
  The server then returns a doorkeeper token that the users then uses from then on to access the app and identify themselves.</p>
  
  <p>This diagram illustrates this:</p>
  
  <p><img src="https://i.stack.imgur.com/tiBcu.png" alt="Client server relationship"></p>
  
  <p>We'd now like to implement a Facebook login from the client, but are having trouble making it work, both theoretically and practically.</p>
  
  <p>On a simple Rails App with Omniauth Identity, you'd simply call auth/facebook, but if we put a link from this in the client, it calls the server and the server then logs:</p>
  
  <p><code>INFO -- omniauth: (facebook) Request phase initiated.</code></p>
  
  <p>The app is set up correctly in Facebook with an ID and Secret, so perhaps the log-in prompt is getting returned to the server?</p>
  
  <p>I'm getting confused though chaining the authentication.  Any help gratefully appreciated!</p>
  
  <p><img src="https://i.stack.imgur.com/gTJ5i.png" alt="enter image description here"></p>