title: Smartfox Server Login + Facebook Single Sign On in a mobile app
body: <p>Goal:</p>
  
  <ul>
  <li>Allow users to authenticate via client side facebook login within a mobile application.</li>
  <li>Use the access token provided by facebook login to authenticate on a SmartFox server that I am hosting.</li>
  </ul>
  
  <p>Details:
  I've done quite a bit of research and the best answers I have found are in these two articles:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/4623974/design-for-facebook-authentication-in-an-ios-app-that-also-accesses-a-secured-we">Design for Facebook authentication in an iOS app that also accesses a secured web service</a></li>
  <li><a href="https://stackoverflow.com/questions/8141037/get-application-id-from-user-access-token-or-verify-the-source-application-for">Get application id from user access token (or verify the source application for a token)</a></li>
  </ul>
  
  <p>Issue:</p>
  
  <ul>
  <li>SmartFox Server's custom login extension makes a synchronous decision about a users credentials. This prevents me from completing step 4 in the first article linked above- our server can't wait for a response from facebook to validate the user's access token before sending a reply to the client (logged in vs. invalid credentials).</li>
  </ul>
  
  <p>Intuitions:</p>
  
  <ul>
  <li>My first thought is to let the user join a lobby as a guest then use regular server commands to validate the access token. Once the access token is validated, the user is then logged into the actual game. I haven't researched this deeply yet, but I'm working on it.</li>
  </ul>
  
  <p>Solved: After implementing the method described above (which worked), I realized that the server could in fact handle querying fb api before returning a login result. Hope this helps someone in the future :)</p>